Access Vba 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 Business Learn more about hiring vba compile error expected = developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask vba compile error expected array Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join vba compile error expected end of statement 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 an individual case, that change needs to be stamped
Excel Vba Compile Error Expected =
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 [Main Details].[Account] = '" & Account & "';" However, I am getting a vba compile error expected function or variable 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 & "' " & _ "AND [Account] = '" & Me!Account & "' " & _ "AND [Status] = 'Made';" Set rst = dbs.OpenRecordset(SQL) On Error GoTo ArrangementNotFound rst.MoveF
help? Post your question and get tips & solutions from a community of 418,417 IT Pros & Developers. excel vba compile error expected expression It's quick & easy. compile errors Expected expression P: 14 JEFFREY MUSGRAY
Compile Error Expected Expression Excel
I have received alot of help from this site and I am grateful. My problem is that
Compile Error Expected End Of Statement
I was able to get the first part of code to work. I tested it via the immediate window. I received the compile error "expected expression" when I http://stackoverflow.com/questions/5031326/how-do-i-fix-this-compile-error-expected-expression tested for function InputFile. ?InputFile(Optional strPath As String) "expected expression" ?InputFile() "expected function or variable" Below is the code that I was given-with slight modification Expand|Select|Wrap|Line Numbers PublicFunctionreadFile(OptionalstrPathAsString)AsString 'Createafilesystemobject DimfsoAsObject Setfso=CreateObject("scripting.filesystemobject") 'Openfileforreading strPath="C:\Users\jeffrey.musgray\Desktop\TcossDocument.txt" readFile=fso.OpenTextFile(strPath,1).ReadAll 'Cleanup Setfso=Nothing EndFunction PublicSubInputFile(OptionalstrPathAsString) DimstrContentAsString strContent=readFile(strPath) DimrsDaoAsDAO.Recordset SetrsDao=CurrentDb.OpenRecordset("SELECT*FROMtblTSR",dbOpenDynaset) rsDao.AddNew WithrsDao ![TSRNumber]=getValue(strContent,101,103) ![TypeAction]=getValue(strContent,103,104) ![TYPEOFSERVICE]=getValue(strContent,104,105) ![RequestingActivity'sRequirementNumber]=getValue(strContent,514) EndWith rsDao.Update SetrsDao=Nothing EndSub https://bytes.com/topic/access/answers/909439-compile-errors-expected-expression Mar 4 '11 #1 Post Reply ✓ answered by gershwyn InputFile is not a function, it is a subroutine. Because it does not return a value, it is not legal to print it (the ? is a shortcut for the print command.) Also, the subroutine takes an optional parameter, which is declared as a string. You don't have to pass anything, but if you do it needs to be a string. Your first attempt is just repeating the sub declaration, which makes no sense in the immediate window. If you want to test your code from the immediate window, the syntax to call it would be either of the following (with or without a parameter): Expand|Select|Wrap|Line Numbers InputFile InputFile"c:\path\to\files\" Share this Question 2 Replies 100+ P: 122 gershwyn InputFile is not a function, it is a subroutine. Because it does not return a value, it is not legal to print it (the ? is a shortcut for the print command.) Also, the subroutine takes an optional parameter, which is declar
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs https://msdn.microsoft.com/en-us/library/a5eydts0.aspx Channel 9 Documentation APIs and reference Dev centers Retired content Samples We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. MSDN http://www.utteraccess.com/forum/msgbox-syntax-vb-code-t1933704.html Library MSDN Library MSDN Library MSDN Library Design Tools Development Tools and Languages Mobile and Embedded Development .NET Development Office development Online Services Open Specifications patterns & practices compile error Servers and Enterprise Development Speech Technologies Web Development Windows Desktop App Development TOC Collapse the table of content Expand the table of content This documentation is archived and is not being maintained. This documentation is archived and is not being maintained. Expression expected Other Versions Visual Studio 2008 Visual Studio 2005  An operator such as + or compile error expected = requires an expression for its right operand, but no recognizable expression appears.Error ID: BC30201To correct this errorSupply a valid expression for the right operand of the operator.See AlsoOperators and Expressions in Visual BasicNotInBuild:Assignment Statements Show: Inherited Protected Print Export (0) Print Export (0) Share IN THIS ARTICLE Is this page helpful? Yes No Additional feedback? 1500 characters remaining Submit Skip this Thank you! We appreciate your feedback. Dev centers Windows Office Visual Studio Microsoft Azure More... Learning resources Microsoft Virtual Academy Channel 9 MSDN Magazine Community Forums Blogs Codeplex Support Self support Programs BizSpark (for startups) Microsoft Imagine (for students) United States (English) Newsletter Privacy & cookies Terms of use Trademarks © 2016 Microsoft © 2016 Microsoft
Custom Search UtterAccess Forums>Microsoft® Access>Access Forms Msgbox syntax - VB code 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|-- 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 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 Catgold22View Member Profile Feb 8 2010, 12:35 AM Post#1Posts: 64Joined: 22-June 09From: TanzaniaHi,This is just a simple question about the syntax of my vb code to use a msgboxMsgBox("Data is OK, No Errors",,"Data Validation",,)I keep getting a "compile error, expected expression" when i run the code, the problem seems to be a the end.Can anyone point out what's wrong with it, what i'm missing?Thanks Catgold22View Member Profile Feb 8 2010, 01:06 AM Post#2Posts