Compile Error Expected Case Vba
Contents |
Question Need help? Post your question and get tips & solutions from a community of 418,469 IT Pros & Developers. It's quick & easy. SQL In VBA vba compile error expected = getting Compile Error: Expected Case 100+ P: 171 iheartvba Hi Everyone, I keep on
Vba Compile Error Expected Array
getting an error saying Compile Error: Expected Case in my (MS Access) VBA What I was trying to do was to do compile error expected expression vba a DSUM function for a Table where the criteria was coming from another table, I later found the criteria needs to be from within the domain table I had set DSUM function (makes sense). I vba compile error expected end of statement then when to Query Bulder to Build The SQL string as Below and put it in VBA Expand|Select|Wrap|Line Numbers PrivateSubtbTotalColl_AfterUpdate() 'ThisshouldgettheSumofAllthetblCollections.Amtfiguresgroupedby 'tblJobDetails.TFN,tblJobDetails.RcptIDisthe1side&tblCollections.RcptID 'istheMANYsideofthetablesrelationship SELECTtblJobDetails.TFN,SumtblCollections.AmtASSumOfAmt_ &FROMtblJobDetailsINNERJOINtblCollectionsONtblJobDetails.RcptID= tblCollections.RcptID_ &GROUPBYtblJobDetails.TFN_ &HAVINGtblJobDetails.TFN=frmPinkCardsMAIN.cboFullNameOr tblJobDetails.TFN EndSub Thanks Apr 8 '07 #1 Post Reply Share this Question 5 Replies Expert 100+ P: 1,017 iburyak Try this: [PHP]SELECT tblJobDetails.TFN, Sum(tblCollections.Amt) AS SumOfAmt _ & FROM tblJobDetails INNER JOIN tblCollections ON tblJobDetails.RcptID = tblCollections.RcptID _ & WHERE tblJobDetails.TFN = frmPinkCardsMAIN.cboFullName
Excel Vba Compile Error Expected =
_ & GROUP BY tblJobDetails.TFN [/PHP] Hope it helps. Apr 8 '07 #2 reply Expert 5K+ P: 8,435 Killer42 The problem is nothing to do with the SQL syntax. It is the fact that you have simply typed SQL into your VBA module. You can't do that. Your VBA code will need to place that SQL statement in a string, and then execute it in some way. Or place it in the appropriate property to have the desired effect - perhaps a form's Filter or RecordSource property, or some such. The error you are receiving indicates that your VBA "Select Case" statement is not correctly written. And since it isn't VBA code, this is hardly surprising. P.S. I have no idea whether the SQL syntax is correct or not - that's another story. Apr 9 '07 #3 reply Expert 100+ P: 1,017 iburyak The problem is nothing to do with the SQL syntax. It is the fact that you have simply typed SQL into your VBA module. You can't do that. Your VBA code will need to place that SQL statement in a string, and then execute it in some way. Or place it in the appropriate property to have the desired effect - perhaps a form's Filter or RecordSource property,
Join INTELLIGENT WORK FORUMSFOR COMPUTER PROFESSIONALS Log In Come Join Us! Are you aComputer / IT professional?Join Tek-Tips Forums! Talk With Other Members vba compile error expected function or variable Be Notified Of ResponsesTo Your Posts Keyword Search One-Click Access To YourFavorite Forums Automated SignaturesOn Your Posts Best Of All, It's Free! Join Us! *Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail. Posting Guidelines Promoting, selling, recruiting, coursework and thesis posting is forbidden.Tek-Tips Posting Policies Jobs Jobs from https://bytes.com/topic/visual-basic/answers/629707-sql-vba-getting-compile-error-expected-case Indeed What: Where: jobs by Link To This Forum! Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.Just copy and paste the BBCode HTML Markdown MediaWiki reStructuredText code below into your site. Microsoft: Access Modules (VBA Coding) Forum at Tek-Tips HomeForumsProgrammersDBMS PackagesMicrosoft: Access Modules (VBA Coding) Forum Compile Error: Expected Case thread705-1183282 http://www.tek-tips.com/viewthread.cfm?qid=1183282 Forum Search FAQs Links MVPs Compile Error: Expected Case Compile Error: Expected Case tbiceps (IS/IT--Management) (OP) 27 Jan 06 13:51 This is a line of code in an application. I get a compile error when I attempt to run this code that states the following:(Compile error:Expected Case)SELECT QryProcessOperationsArea.[Report ID], QryProcessOperationsArea.[Customized or Standard], QryProcessOperationsArea.[Report Title], QryProcessOperationsArea.[ApplicationProducing Report], QryProcessOperationsArea.[Report Type] FROM QryProcessOperationsArea;I copied this line of code from the row source of the specific form. Does anyone have any clues? RE: Compile Error: Expected Case SkipVought (Programmer) 27 Jan 06 14:17 You did not provide any VB code -- just SQL.Where is your code? Skip, Be Advised! For those this winter, caught in Arctic-like calamity, be consoled...Many are cold, but few are frozen! RE: Compile Error: Expected Case tbiceps (IS/IT--Management) (OP) 27 Jan 06 15:57 This is SQL code generated by access in the QBE window. My goal is to convert this SQL statement into a VBA readable format. However, I will insert the SQL statement in the following
Custom Search UtterAccess Forums>Microsoft® Access>Access Modules Compile Error Expected:Case Help Forum HomeSearchHelpUA Messages|-- http://www.utteraccess.com/forum/Compile-Error-ExpectedCa-t1833594.html UtterAccess.com NewsAccess Knowledge Center|-- Access Code Archive|-- Access Knowledgebase http://www.computerperformance.co.uk/Logon/code/code_800A03FD.htm / 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 + compile error 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 compile error expected 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 kstonemanView Member Profile May 26 2009, 10:48 AM Post#1Posts: 435Joined: 25-September 03From: KansasI am trying to convert a Access query to a SQL statement with no luck. I am getting a Compile Error Expected: Ca
jokes Introduction to Code 800A03FD Error code, 800A03FD occurs when you execute a VBScript 'Select' statement. The problem is you are using Select but without the corresponding 'Case' statement. There are two variations of this error: Example 1 WMI Example 2 Pure Select Case For both Examples, the Symptoms you get The script does not execute as you had hoped. Instead. Windows Scripting host generates a message box like this picture: For both Examples the Cause of Code 800A03FD Your VBScript contain is missing a argument.Source: Microsoft VBScript compilation error, indicates an syntax error in a statement in your script. Compilation errors such as missing brackets are easy, but problems with Select ... Case are more subtle. For more help let us check is the Line: number, (12 in example 1). The Solutions The Windows Scripting Host gives us three useful clues, firstly, look on Line: 10, do count any remark or empty lines. Secondly, the Char: number 8, is very useful in tracing the error. Thirdly, there is something wrong with the Select statement, which is confirmed in the message by Error: Expected 'Case'. The underlying problem is that Select * is inappropriate here. In VBScript 'Select' requires Case. 'Select * from... WHERE' is an SQL construction that is misused in this example. If you employ Select, then is should be in brackets:(Select * from colaccounts). There should be no 'Where' clause. ‡ Example 1 of Script showing Error 800A03FD Check the Select * The problem is that you cannot saywhere objAccount.name = "Guest". Try Removing the where statement alltogether. 'VBScript to Enumerate Accounts, and SID On Error Resume Next if Err <> 0 Then set lasterr = CreateObject("WbemScripting.SWbemLastError") Wscript.echo lasterr.Operation End if set objWMIService = GetObject("Winmgmts:\\" & strComputer) set colAccounts = objWMIService.InstancesOf("win32_Account") For each objAccount In colAccounts Select * from colaccounts where objAccount.name = "Guest" WScript.echo "Name " & objAccount.name & vbCRLf & _ "SID : " & objAccount.SID & vbcrlf & _ "Sid Type : " & objAccount.SIDType & vbcrlf & _ "Status : " & objAccount.Status & vbcrlf & _ "Domain : " & objAccount.Domain & vbcrlf & _ "Caption : " &