Ms Access 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
Compile Error Expected = Vba
Learn more about Stack Overflow the company Business Learn more about hiring developers compile error expected = msgbox or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack vba expected = when calling sub 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: Sign up ms access - vba: Compile Error: expected:
Excel 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 (" & stageName & "," & percentageValue & ");" DoCmd.SetWarnings False DoCmd.RunSQL sSQL End Sub and I call it from another subroutine as below economy =
Vba Compile Error Byref Argument Type Mismatch
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 378215 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 57.4k74263 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
Community Links Social Groups Pictures & Albums Members List Calendar Search Forums Show Threads Show Posts Tag Search Advanced Search Find All Thanked Posts Go to Page... Thread Tools Rate Thread Display Modes 01-14-2003, 10:04 AM #1 MaxNEMC Guest vba compile error expected end of statement Posts: n/a Compile Error: Expected: = I wrote a function that I want to have
Expected Sub Function Or Property
3 parameters for Import_Reports(tblName as String, Specs as String, InputDir as String) When i try to run it, i get: Compile Error: Expected = compile error expected list separator or ) BUT If i define 2 of the parameters within the function as vars, leaving only one as an argument, it works fine. I can use any one of the 3 alone as an argument and it works, but any more http://stackoverflow.com/questions/31329829/ms-access-vba-compile-error-expected than 1 and i get that compile error... i'm stumped! Any help would be greatly appreciated! Max 01-14-2003, 10:49 AM #2 Fornatian Dim Person Join Date: Aug 2000 Location: England Posts: 1,396 Thanks: 0 Thanked 0 Times in 0 Posts Max, A compile error of this nature means that a variable is missing an assignment somewhere. Can you post your code? Also, can you elaborate on.. Quote: If i define 2 of the http://www.access-programmers.co.uk/forums/showthread.php?t=40303 parameters within the function as vars, leaving only one as an argument... __________________ Ian build a better system and they'll build a better idiot. Fornatian View Public Profile Find More Posts by Fornatian 01-14-2003, 10:58 AM #3 MaxNEMC Guest Posts: n/a Function Import_Reports(Specs As String, tblName As String, InputDir as string) Dim ImportFile, ImportErrors As String 'Dummy As Integer 'InputDir = "c:\windows\desktop\adhocrpts\" 'Specs = "Highland Import Specs" ImportFile = Dir(InputDir & "\*.txt") 'Sets the Filename to be imported Do While Len(ImportFile) > 0 'tblName = Left(ImportFile, (InStr(1, ImportFile, ".") - 1)) 'This is to import each file into individual tables 'tblName = "Highland_Raw" DoCmd.TransferText acImportFixed, Specs, tblName, InputDir & ImportFile, False 'DoCmd.RunMacro "Highland" 'DoCmd.DeleteObject acTable, tblName ImportErrors = (Left(ImportFile, (InStr(1, ImportFile, ".") - 1)) & "_ImportErrors") DoCmd.DeleteObject acTable, ImportErrors ImportFile = Dir Loop ---------------------------- heh, sorry about that.... what i mean is, if instead of having 3 parameters to be passed to the function, if i only give it one and then define the other 2 as string variables and assign them their values within the body of the function, then the code works.... 01-14-2003, 11:57 AM #4 Drevlin Data Demon Join Date: Jul 2002 Location: Durham, NC USA Posts: 135 Thanks: 0 Thanked 0 Times in 0 Posts I don't believe the problem is with your function. The problem is m
soon) Ruby (coming soon) Getting Started Code Samples Resources Patterns and Practices App Registration Tool Events Podcasts Training API Sandbox https://msdn.microsoft.com/en-us/library/office/gg264652.aspx Videos Documentation Office Add-ins Office Add-in Availability Office Add-ins Changelog http://arstechnica.com/civis/viewtopic.php?t=108545 Microsoft Graph API Office 365 Connectors Office 365 REST APIs SharePoint Add-ins Office UI Fabric Submit to the Office Store All Documentation https://www.yammer.com/ http://feeds.feedburner.com/office/fmNx Office VBA language reference Visual Basic language reference Error Messages Error Messages Expected Function or variable Expected Function or compile error variable Expected Function or variable #Else clause must be preceded by a matching #If #Else If, #Else, or #End If must be preceded by a matching #If #ElseIf must be preceded by a matching #If or #ElseIf and followed by an #ElseIf, #Else, or #End If
Case and Cooling Fetish CPU & Motherboard Technologia Mobile Computing Outpost Networking Matrix Other Hardware Agora Classifieds Ars DIY Forum (Name TBD!) Operating Systems & Software Battlefront Microsoft OS & Software Colloquium Linux Kung Fu Windows Technical Mojo Distributed Computing Arcana Macintoshian Achaia Programmer's Symposium The Server Room Ars Lykaion Gaming, Extra Strength Caplets The Lounge The Soap Box The Boardroom The Observatory Ars Help & Feedback Ars Subscription Member Areas Image Galleries MS Access VBA Newbie question - "Compile Error: Expected: List Separator or )" 3 posts ScruffyNerf "Very Little Gravitas Indeed" Ars Tribunus Angusticlavius Tribus: Adelaide, South Australia Registered: Sep 4, 2006Posts: 8373 Posted: Sat Sep 13, 2008 6:47 am 'Evening,I've been given a task to create a MS Access db for a community support network, and have run into a small bug. As a part of this, I've created a form for data entry of new people to tblPeople. Currently, I'm attempting to get a duplicate search performing when data is entered in the form, and am getting the above error.Please note that this is pretty much my first foray into VBA code, and the code itself was kludged together from various places on the net, including the experts-exchange site.Table details:PeopleID: Autonumber Primary KeyFamilyName (Text)PreferredName (Text)Form Details:On the 2nd tab field (PreferredName), I've created a 'BeforeUpdate' Event procedure calling the following VBA code: Private Sub PreferredName_BeforeUpdate(Cancel As Integer) Dim sWhere As String Dim lID As Long 'If both name fields have a value If Nz(FamilyName.Value, "") <> "" And Nz(PreferredName.Value, "") <> "" Then *** lID = VAL(NZ(DLOOKUP("PeopleID","tblPeople","FamilyName = '" & FamilyName.Value & "' AND PreferredName = '" & PreferredName.Value & "'),0)) *** 'see if record returned i.e., lID>0 and it if does not match current id on form then its duplicate If lID <> PeopleID.Value Then MsgBox "Possible duplicates exist. Please do a search for this name before continuing." Cancel = True End If End If End Sub The starred line is what appears to be throwing the compile error, but I have no idea as to why. What am I missing? Any help would be appreciated. Azzmodan Ars Praetorian Tribus: T