Compile Error Expected
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss compile error expected end of statement vb6 the workings and policies of this site About Us Learn more about
Compile Error Expected Variable Or Procedure Not Module Access
Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow compile error expected end of statement access 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 you, helping each
Compile Error Expected Variable
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 as below Public Sub updateStagesTable(sName As String, percentageValue As Double) stageName = "'" & sName & "'" sSQL = "INSERT INTO StagesT ([Stage Name], [Stage Value In Percentage]) VALUES compile error expected list separator or ) access (" & 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 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 56.6k74163 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,68821144 answered Jul 24 '15 at 11:00 PeterTaylorXC 111 add a comment|
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
Compile Error Expected End Of Statement Access Vba
company Business Learn more about hiring developers or posting ads with us Stack Overflow
Compile Error Expected List Separator Or )
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 named parameter vba million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up VBA returning error when calling a Sub with multiple parameters up vote 9 down vote favorite 2 I'm trying http://stackoverflow.com/questions/31329829/ms-access-vba-compile-error-expected to figure out why VBA is returning an error (Compile error: Expected: =)when I call a Sub and supply it with multiple parameters. Any help would be highly appreciated. Sub customerController(cleanStructure As Boolean, firstCol As Integer, latCol As Integer, _ lngCol As Integer, Optional startRow As Long, Optional endRow As Long) Dim i As Long, j As Long, n As Long If (cleanStructure = False) Then 'customer data type If (startRow = "") http://stackoverflow.com/questions/13624279/vba-returning-error-when-calling-a-sub-with-multiple-parameters Then i = 1 If (endRow = "") Then j = countRows For n = i To j - i + 1 generateURL(n, firstCol) newReadXMLData (url) ActiveSheet.Cells(i, latCol).Value = lat ActiveSheet.Cells(i, lngCol).Value = lng Next End If End Sub The Sub that I'm calling requires two parameters: Sub generateURL(row As Long, column As Long) excel vba excel-vba share|improve this question edited Mar 28 '15 at 10:12 brettdj 38.6k1563109 asked Nov 29 '12 at 11:00 MartinUKPL 1232313 2 can you post the code for how you are calling it? You have posted customerController but referring to readAddress? –InContext Nov 29 '12 at 11:07 Oops, I posted the wrong function in the last line. I get the error in the generateURL(n,firstcol) line. –MartinUKPL Nov 29 '12 at 11:13 change generateURL(n, firstCol) to generateURL n, firstCol –chris neilsen Nov 29 '12 at 11:14 also dim firstCol as Long, or you will get another error –user1135218 Nov 29 '12 at 19:28 1 Spent a few tens of minutes trying to figure out what the problem was as I was getting the exact same error message. This question and the answer saved me. Makes you wonder why they would have such a cryptic error message and unusual syntax. –Adam Jensen Mar 12 '15 a
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 I find the environment a little unfriendly and the language a bit scary! I used to write BBC Basic 20+ years ago and MS http://www.vbaexpress.com/forum/archive/index.php/t-33922.html 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 "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 compile error would like to assign and do something with the result. Strangely I have a function with just 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 compile error expected 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, and you can call the two argument function as well, but there is no point in assigning it a return type of range if you aren't capturing it as a range, and no point in setting a value in the function as you are just throwing it away with a call. rubinho09-07-2010, 08:36 AMIt works fine for me, which suggests that there is more that we are not (yet) aware of. Yes, the same thought was dawning on me too. I'm thinking typo but I've been staring at it trying to figure it out to no avail. Is there a length at which a function name no longer becomes unique, i.e. does it only check the first 13 letters or less? Do arguments need to have unique names between different functions? If I cut and paste the declaration of this function befor