Docmd.openform 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 of this site About Us Learn more about Stack Overflow the company compile error expected expression vba Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs compile error expected expression access vba Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, compile error expected expression excel just like you, helping each other. Join them; it only takes a minute: Sign up How do I fix this compile error: “Expected: Expression” up vote 0 down vote favorite When a user updates the status of visual basic compile error expected expression 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 into the form. DoCmd.RunSQL "UPDATE [Main Details] " & _ "SET [Main Details].[Status] = '" & Status & "' " & _ "AND [Main Details].[On Hold] = '" & On Hold & "' " & _ "WHERE
Vba Expected Expression
[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] = '" & Status & "' " & _ "AND [Main Details].[On Hold] = '" & On Hold & "' " & _ "WHERE [Main Details].[Account] = '" & Account & "';" DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70 Select Case Me!ReportSelection Case "Write Email" DoCmd.OpenForm "CaseEmail", acNormal, , , acFormEdit, acWindowNormal Exit Sub Case "Arrangement Letter" Set dbs = CurrentDb DoCmd.RunSQL "SELECT * FROM [Arrangements] " & _ "WHERE [Client] = '" & Me!Client &
here for a quick overview of the site Help Center Detailed answers to any questions you might have
Compile Error Expected End Of Statement
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 4.7 million programmers, just like http://stackoverflow.com/questions/5031326/how-do-i-fix-this-compile-error-expected-expression you, helping each other. Join them; it only takes a minute: Sign up VBA - Why do I get a compile error expected function or variable up vote 0 down vote favorite I am curious to understand why the following throws and compile error stating it is expecting a function or variable Dim frm as Form http://stackoverflow.com/questions/30197145/vba-why-do-i-get-a-compile-error-expected-function-or-variable set frm = DoCmd.OpenForm(FormName:=mstr_FORM_NAME, View:=acDesign, WindowMode:=acHidden) but I can do this DoCmd.OpenForm FormName:=mstr_FORM_NAME, View:=acDesign, WindowMode:=acHidden set frm=Forms(mstr_FORM_NAME) I have no issue with doing what works, I just want to understand what is going on with the former statement. Thank you, Fred vba access-vba share|improve this question asked May 12 '15 at 16:57 Fred Wilson 21519 possible duplicate of Compile Error: Expected function or variable in VBA for access –Ken White May 12 '15 at 17:03 Ken, I read the referenced post before I posted here but the post did not seem to address answer my question or confusion. –Fred Wilson May 12 '15 at 17:33 add a comment| 2 Answers 2 active oldest votes up vote 2 down vote accepted DoCmd.OpenForm is a method which doesn't return a value. In the second code snippet you are accessing the Forms Collection, which contains the form, after it has been opened by DoCmd.OpenForm. When you call a method, you must not specify braces. share|improve this answ
for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Ask a Question Ask for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get https://www.experts-exchange.com/questions/22049159/DoCmd-Openform-WhereCondition-Type-Mismatch.html Help Expand Search Submit Close Search Login Join Today Products BackProducts Gigs Live Careers https://www.tutcity.com/access/docmd-openform-syntax-error.32309.html Vendor Services Groups Website Testing Store Headlines Experts Exchange > Questions > DoCmd Openform WhereCondition Type Mismatch Want to Advertise Here? Solved DoCmd Openform WhereCondition Type Mismatch Posted on 2006-11-04 MS Access 1 Verified Solution 10 Comments 837 Views Last Modified: 2008-02-01 Hi Have some code that looks like this but returns type mistype error. Dim stDocName compile error As String Dim stLinkCriteria As String stDocName = "ChooseAuditReadOnly" stLinkCriteria = "[AuditNumber]= " & Me![AuditNumber] And "[Auditor] = " & Me![Auditor] If I take out the "And" clause it works fine; so there is some problem with And "[Auditor] = " & Me![Auditor] The data types are matched so not sure what the problem is. Thank you 0 Question by:ohgee Facebook Twitter LinkedIn Google LVL 119 Active today Best Solution byRey compile error expected Obrero if field type of data is number use " like this "[AuditNumber]= " & Me![AuditNumber] text add a single quote like this "[Auditor] = ' " & Me![Auditor] & " ' " Go to Solution 10 Comments LVL 142 Overall: Level 142 MS Access 27 Message Active today Expert Comment by:Guy Hengel [angelIII / a3]2006-11-04 the AND needs to be part of the string: stLinkCriteria = "[AuditNumber]= " & Me![AuditNumber] " And [Auditor] = " & Me![Auditor] 0 Message Author Comment by:ohgee2006-11-04 Thanks, tried this but now get compile error: expected end of statement. When I had the And outside of the string seems that correct values being being passed to the &Me statements. 0 Message Author Comment by:ohgee2006-11-04 ....correct values were being passed to the &Me statements. 0 LVL 65 Overall: Level 65 MS Access 59 Message Expert Comment by:rockiroads2006-11-04 Is Auditor a String field? does it contain text? you did say data types match, but is that on table level? stLinkCriteria = "[AuditNumber]= " & Me![AuditNumber] And "[Auditor] = '" & Me![Auditor] & "'" 0 LVL 119 Overall: Level 119 MS Access 119 Message Active today Expert Comment by:Rey Obrero2006-11-04 try any of these stLinkCriteria = "[AuditNumber]= " & Me![AuditNumber] &" And [Auditor]
, "ProcName= & Me.ProcName" Sponsored Links: Read full post... Report an issue Thank you for taking the time to report an issue. What's wrong... Please write below. And write your email address (optional) Similar posts... Argument not optional I am writing some code for a database button but the error message argument not optional appears, saying that my OpenForm is incorrect. Private Sub Command47_Click() DoCmd.OpenForm.[tbljobs main] DoCmd.GoToRecord , , acNewRec DoCmd.ApplyFilter "jobs form search set focus specific form I have a problem with regards with the setfocus of certain form. I have a command button that will open several forms and once open I want to setfocus it in "Purchase Requisition" form. please see code below Private Sub Login_Click() Dim Password As Variant Password = DLookup("Password", "Users", "UserID = '" & Me.txtUserID & "' ") If Nz(Password, "") = Me.txtpassword Then DoCmd.Close DoCmd.OpenForm "Purchase Requisition" DoCmd.OpenForm "Purchase Order" DoCmd.OpenForm "Supplier Information" DoCmd.OpenForm "Archive" DoCmd.OpenForm "Others" Else MsgBox "Incorrect user ID or password" End If End Sub DoCmd.OpenForm Expected I'm attempting to pull a row of data in a table by opening a separate form using the DoCmd.OpenForm command. I have raw data that is copied into a text box and the code pulls out the time, tech and customer. That all works fine but the OpenForm is failing me! I CAN run the code as follows: docmd.openform Invalid database object reference I have a problem and I hope you will agree to help me. After modifying database links (front end to new backend), one form does not open and generated reference error 3276. I open the form by clicking on tree control node. but It does not open directly from DB window. but, If I compact & Repair the file it opens correctly. What should I do in order to ovoid this error ? Private Sub menuTree_Click() Dim strcrit As String stricrit = menuTree.SelectedItem.Key DoCmd.Close DoCmd.OpenForm stricrit End Sub What is wrong with my Openform code? I have a button which opens a form