Docmd.openform Compile Error Expected
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 compile error expected = vba more about Stack Overflow the company Business Learn more about hiring developers or
Vba Expected = When Calling Sub
posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community compile error expected = msgbox Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Issue using VB in access to open up form
Vba Compile Error Expected Sub Function Or Property
with OpenForm up vote 0 down vote favorite I have a Inventory form. I want to create an Update button which, when clicked, will open up a new form frm_add-remove, which will contain only the selected inventory item and will allow you to edit the stock quantity. I have listed the click event below, and it doesn't work: Private Sub A_Click() Dim var As Variant var = Forms![frm_Inventory]![ItemID] excel vba compile error expected DoCmd.OpenForm(frm_add-remove, , , "ItemID = " & var, , , ) End Sub and got a compilation error, Expected: expression. ItemID is a column in the frm_Inventory table, as well as in the frm_add-remove table. I tried with and without the trailing commas. Do I have a syntax error? I thought that you can concatenate with either + or &? ms-access access-vba ms-access-2013 share|improve this question edited Jun 10 '13 at 21:41 PowerUser 6,97194478 asked Jun 10 '13 at 21:08 user1015214 80641833 Do any itemID values have any single or double quotes in them e.g. ' or "? –PowerUser Jun 10 '13 at 21:42 no, they do not. –user1015214 Jun 11 '13 at 0:44 add a comment| 2 Answers 2 active oldest votes up vote 1 down vote accepted Try: DoCmd.OpenForm("frm_add-remove", , , "ItemID = '" & var & "'", , , ) I did 2 things. Put frm_add-remove in quotes so it gets passed properly as a string and not as a variable name. Put var in quotes in case it is also a string. share|improve this answer answered Jun 10 '13 at 21:45 PowerUser 6,97194478 now I get the compile error: expected: = –user
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
Access Vba Compile Error Expected
Business Learn more about hiring developers or posting ads with us Stack Overflow Questions
Vba Compile Error Expected Function Or Variable
Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, vba compile error expected end of statement just like 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 http://stackoverflow.com/questions/17032905/issue-using-vb-in-access-to-open-up-form-with-openform curious to understand why the following throws and compile error stating it is expecting a function or variable Dim frm as Form 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 http://stackoverflow.com/questions/30197145/vba-why-do-i-get-a-compile-error-expected-function-or-variable 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 answer answered May 12 '15 at 17:03 Peter Schneider 88769 Well that makes perfect sense. I guess I just didn't understand well enough the idea of a method not returning a value. Thanks Peter. –Fred Wilson May 12 '15 at 17:30 add a comment| up vote 2 down vote The OpenForm method (doc) is not returning anything, just opening the form (not returning it). So, you're trying to cast Nothing into a variable defined As Form. Instead, frm (having the Set frm = statement) is expecting to "become something", it is expecting a function or variable - a value, to be clear). s
Custom Search UtterAccess Forums>Microsoft® Access>Access Forms OpenForm Method, "Expected =" error http://www.utteraccess.com/forum/openform-method-expecte-t1412543.html Forum HomeSearchHelpUA Messages|-- UtterAccess.com NewsAccess Knowledge Center|-- Access Code Archive|-- Access Knowledgebase / FAQ|-- Access TutorialsMicrosoft® Access|-- Local Access User Groups (AUGs)|-- Interface Design|-- Access Q and A|-- Access Tables + Relationships|-- Access Queries|-- Access Forms|-- Access Reports|-- Access Macros|-- Access Modules|-- compile error Access Date + Time|-- Access Errors + Error Handling|-- Access Built-in Functions|-- Access Searching + Data Mining|-- Access Records|-- Access Security|-- Access Automation|-- Access Database Container|-- Tool bars, Menu bars + Ribbon|-- Access Services (Web Databases)|-- Access Data Access Pages (Deprecated)|-- Access Data compile error expected Projects - ADP|-- Access Runtime, Packaging & DeploymentAnd More...|-- Microsoft SQL Server|-- SQL Server Reporting Services|-- Microsoft SharePoint|-- Microsoft Internet Explorer|-- Visual Basic 6 and Earlier|-- Visual Basic 2003 and Later|-- ASP and VBScript|-- Web Development|-- PHP, Perl, MySQL and Postgres|-- Other Database Engines|-- BI Tools and Applications|-- JAVA and C#|-- GraphicsMicrosoft® Office|-- Microsoft Excel|-- Microsoft Excel FAQs|-- Microsoft Word|-- Microsoft Outlook|-- Microsoft PowerPoint|-- Microsoft FrontPage/Exp. Web|-- Other Microsoft ProductsPC|-- Network Issues|-- Q & A - Hardware|-- Q & A - Software|-- Q & A - Other PC|-- Virus + Security DiscussionUtterAccess Odds and Ends|-- General Chat|-- Q & A - UtterAccess.com Forums|-- Q & A - Access Wiki Options sarahfalkView Member Profile May 8 2007, 08:28 AM Post#1Posts: 58Joined: 1-February 07From: WI, USAHi! I'