Ms Access Compile Error Expected Expression
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies compile error expected expression vba of this site About Us Learn more about Stack Overflow the company
Compile Error Expected Expression Excel
Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges visual basic compile error expected expression Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute:
Vba Expected Expression
Sign up How do I fix this compile error: “Expected: Expression” up vote 0 down vote favorite When a user updates the status of an individual case, that change needs to be stamped across all cases under the account number. Within the VB, I am trying to use the following SQL to update the table with the information the user has put compile error expected end of statement into the form. DoCmd.RunSQL "UPDATE [Main Details] " & _ "SET [Main Details].[Status] = '" & Status & "' " & _ "AND [Main Details].[On Hold] = '" & On Hold & "' " & _ "WHERE [Main Details].[Account] = '" & Account & "';" However, I am getting a compilation error, and I suspect it is something to do with "On Hold". How can I correct this? Any help with this will be greatly appreciated. For context, I am looking at a combo box called "ReportSelection" on a form called "Main Details". Within the "After Update" event procedure, there is the following code: Private Sub ReportSelection_AfterUpdate() If ReportSelection = "Enforcement Letter" Or ReportSelection = "Fees Letter" Or ReportSelection = "Follow On Letter" Or ReportSelection = "Reminder Letter BO" Or ReportSelection = "Reminder Letter CR" Or ReportSelection = "Reminder Letter CT" Or ReportSelection = "Reminder Letter NNDR" Or ReportSelection = "Reminder Letter RTD" Or ReportSelection = "Reminder Letter SD" Then CmbStatus = "HOLD Until" [On Hold] = Date + 5 End If DoCmd.RunSQL "UPDATE [Main Details] " & _ "SET [Main Details].[Status] = '"
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, http://stackoverflow.com/questions/5031326/how-do-i-fix-this-compile-error-expected-expression just like you, helping each other. Join them; it only takes a minute: Sign up Compile Error: Expected Case up vote 1 down vote favorite I have an event procedure of the form to Execute a series of Append query statements to create the new related records. I am getting a "Compile Error: Expected Case" http://stackoverflow.com/questions/35021319/compile-error-expected-case the SELECT Inquiries.InquiryID of the code is red. The exact code is pasted below. Private Sub Form_AfterInsert() Dim db As DAO.Database Dim strSQL As String Set db = DBEngine(0)(0) strSQL = "INSERT INTO PreCallQuestionaireResidential ( InquiryID )" SELECT Inquiries.InquiryID FROM Inquiries db.Execute strSQL Set db = Nothing End Sub ms-access access-vba ms-access-2007 share|improve this question edited Jan 26 at 18:50 HansUp 79.3k114371 asked Jan 26 at 18:39 AJK 102 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted When Access sees SELECT unquoted, it expects that to be part of a Select Case code block. You want your SELECT included in the strSQL string ... strSQL = "INSERT INTO PreCallQuestionaireResidential ( InquiryID )" & vbCrLf & _ "SELECT Inquiries.InquiryID FROM Inquiries" Debug.Print strSQL '<- view this in Immediate window; Ctrl+g will take you there share|improve this answer answered Jan 26 at 18:46 HansUp 79.3k114371 Also, for better information in the event of problems, consider using the dbFailOnError
Ian Grieve Certifications & Training Microsoft MCP Profile Privacy Policy Submit Question Links VBA Compile Error - Expected: expression ● Ian Grieve ● Tuesday 30th July 2013 ● 2 Comments ● I realise that the use of VBA in modifications http://www.azurecurve.co.uk/2013/07/vba-compile-error-expected-expression/ and customisations is something that needs to be carefully considered with Microsoft Dynamics GP 2013 including a Silverlight based Web Client which cannot use VBA. I had a requirement from a client for a modification to the Debtor Enquiry (Customer Inquiry to the Americans reading) to include the sum of the displayed transactions on the window and as this was a small client with GP installed locally on each PC compile error there is no requirement for the web client, I felt able to perform this change using Modifier using some VBA. I added the required fields to the VBA project but encountered an error message when writing the VBA code to concatenate the fields into the SQL statement I was going to use to get the data; Microsoft Visual Basic: Compile error: Expected: expression It took me a few minutes to compile error expected realise that the cause of the error is that To is a restricted keyword in VBA. Once I had realised this, I was able to quickly work around the error by updating the code to refer to the field To with more accuracy; The red ringed text shows how I got VBA to accept the variable. The Me refers to the Debtor Enquiry window and specifies that To is not a keyword but a child object of the window. What should we write about next? Your Name (required) - Your Email (required) - What is 2x2? Please leave this field empty. Related posts: EFT File Format Import/Export Error Customisation Import - Component Write Exception Mark Polino's Weekly MS Connect Suggestion - See Checkbook on Cash Receipts Inquiry MDGP 2013 Feature of the Day: Print on Picklist Shortage Enquiry Area Page Error - Value Cannot be Null Microsoft Dynamics GP 2013 Web Client Unexpected Error ● Categories: Dynamics, GP, Microsoft, Modifier with VBA ● Tags: Enquiry/Inquiry, Error, GP, Microsoft, Microsoft Dynamics, Modifier with VBA, VBA ● Permalink ● Shortlink ● 2 Responses Pingback: VBA Compile Error – Expected: expression : Interesting Findings & Knowledge Sharing David Musgrave 31st July 2013 / 04:08 Hi Ian You might find this blog post relevant to this issue. http://blogs.msdn.com/b/developingfordynamicsgp/archive/2012/09