Expected Compile Error
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 compile error expected end of statement the company Business Learn more about hiring developers or posting ads with us Stack Overflow
Compile Error Expected Vba
Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 compile error expected end sub million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up ms access - vba: Compile Error: expected: = up vote 1 down vote favorite 1 I have a subroutine compile error expected list separator or as below Public Sub updateStagesTable(sName As String, percentageValue As Double) stageName = "'" & sName & "'" sSQL = "INSERT INTO StagesT ([Stage Name], [Stage Value In Percentage]) VALUES (" & stageName & "," & percentageValue & ");" DoCmd.SetWarnings False DoCmd.RunSQL sSQL End Sub and I call it from another subroutine as below economy = 3.53 updateStagesTable ("Economy", economy) But I get this compile error Compile Error: expected: = I don't understand
Compile Error Expected Function Or Variable
what I am doing wrong here. Please help. vba access-vba share|improve this question asked Jul 9 '15 at 23:08 user1670773 373215 add a comment| 2 Answers 2 active oldest votes up vote 6 down vote accepted updateStagesTable ("Economy", economy) should be updateStagesTable "Economy", economy with no parentheses See related: Unexpected results from typename share|improve this answer answered Jul 9 '15 at 23:27 Tim Williams 57k74163 add a comment| up vote 1 down vote I have never liked this peculiarity of VB so I always use the alternate CALL syntax, in your case this would be: Call updateStagesTable("Economy", economy) which does allow the parentheses that all other languages expect share|improve this answer edited Aug 4 at 9:21 Gareth 2,69321144 answered Jul 24 '15 at 11:00 PeterTaylorXC 111 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service. Not the answer you're looking for? Browse other questions tagged vba access-vba or ask your own question. asked 1 year ago viewed 3294 times active 2 months ago Linked 1 Unexpected results from typenam
be down. Please try the request again. Your cache administrator is webmaster. Generated Sat, 15 Oct 2016 10:02:27 GMT by s_wx1094 (squid/3.5.20)
AMBackground; I'm a C++/C# Windows programmer who has delved into an Excel VBA project. I've played with it a bit before but http://www.vbaexpress.com/forum/archive/index.php/t-33922.html I find the environment a little unfriendly and the language a bit scary! I used to write BBC Basic 20+ years ago and MS QuickBASIC about 15 years ago! I have a function declared: Function FindX(ByVal First as Integer, ByVal Second as Integer) As Range Set FindX = Cells(1, 1) End Function If I reference: FindX(1, 2) from a Proc I get a compile error compile error "Expected: =". I've done some digging and I have tried the following: FindX 1, 2 ' get rid of the parentheses Call FindX(1, 2) ' use the Call keyword Neither of these do what I want. Ultimately, the function will do something useful and I would like to assign and do something with the result. Strangely I have a function with just compile error expected one parameter which is declared and referenced in exactly the same way which works just fine. I'm very confused! xld09-07-2010, 08:12 AMIt is returning a range object, so you need to assign it to a range object Set rng = FindX(1, 2) rubinho09-07-2010, 08:19 AMIt is returning a range object, so you need to assign it to a range object Set rng = FindX(1, 2) I was just about to add, if I do assign it to a range object e.g. Dim thing As Range Set thing = FindX(1, 2) I get an error saying "Object variable or With block variable not set". My other identical-except-for-having-just-one-argument Function I can reference simply FindY(1) without any assignment. xld09-07-2010, 08:26 AMI was just about to add, if I do assign it to a range object e.g. Dim thing As Range Set thing = FindX(1, 2) I get an error saying "Object variable or With block variable not set". It works fine for me, which suggests that there is more that we are not (yet) aware of. My other identical-except-for-having-just-one-argument Function I can reference simply FindY(1) without any assignment. You can, a