Ms Access Compile Error Expected Case
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 developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack 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 Compile Error: Expected Case up vote 1 down vote favorite I have an event procedure of the form to Execute a series of Append query statements to create the new related records. I am getting a "Compile Error: Expected Case" the SELECT Inquiries.InquiryID of the code is red. The exact code is pasted below. Private Sub Form_AfterInsert() Dim db As DAO.Database Dim strSQL As String Set db = DBEngine(0)(0) strSQL = "INSERT INTO PreCallQuestionaireResidential ( InquiryID )" SELECT Inquiries.InquiryID FROM Inquiries db.Execute strSQL Set db = Nothing End Sub ms-access access-vba ms-access-2007 share|improve this question edited Jan 26 at 18:50 HansUp 79.3k114371 asked Jan 26 at 18:39 AJK 102 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted When Access sees SELECT unquoted, it expects that to be part of a Select Case code block. You want your SELECT included in the strSQL string ... strSQL = "INSERT INTO PreCallQuestionaireResidential ( InquiryID )" & vbCrLf & _ "SELECT Inquiries.InquiryID FROM Inquiries" Debug.Print strSQL '<- view this in Immediate window; Ctrl+g will take you there share|improve this answer answered Jan 26 at 18:46 HansUp 79.3k114371 Also, for better information in the event of problems, consider using the dbFailOnError option with db.Execute strSQL –HansUp Jan 26 at 18:52 It worked. Many thanks. –AJK Jan 27 at 7:48 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 ms-access access-vba ms-access-2007 or ask your own question. asked 8 months ago viewed 289 times active 8 months ago Related 2Error when running Access 2003 app in Access 20070Error handling event of control on subform4MS Access “Update or CancelUpdate” error using Find dialog0TempVars in Select Case1Access VBA Dimension only storing expected value the first
be down. Please try the request again. Your cache administrator is webmaster. Generated Thu, 20 Oct 2016 17:08:33 GMT by s_nt6 (squid/3.5.20)
can't figure out what I am doing wrong. I have followed all the syntax that I can find in my reference material and keep getting the same results - ERRORS on compile and syntax. Select * FROM rsaddress WHERE http://www.xtremevbtalk.com/archive/index.php/t-153087.html LName = ssTab1.Caption This gives me the error "Compile Error: Expected: Case" and highlights the '*' I keep getting this same kind of error whenever I try to use any SQL statements. Someone please point me in the right http://www.computerperformance.co.uk/Logon/code/code_800A03FD.htm direction. Am I missing a connection that I need for SQL or is the some declarative I need ?? rsaddress = an ADODB recordset that is defined in the option explicit. LName = the last name as stored in ms access the ADODB recordset. ssTab1.Caption is a tab with the letter of the last name I have done some displays and sstab1.caption displays correctly, the number of records in the file match what has been input to the file. I am pulling my hair out and bald women don't really look good. PLEASE HELP !!!! Jenn :confused: Marathon Man03-15-2004, 06:35 AMHow are you actually using the line of SQL - is it the Source property of the Recordset object? dwall03-15-2004, ms access compile 07:08 AMIs your SQL line like this strSQL = "Select * FROM rsaddress WHERE LName = ssTab1.Caption" if so try strSQL = "Select * FROM rsaddress WHERE LName = '" & ssTab1.Caption & "'" jennie_195103-15-2004, 07:11 AMHow are you actually using the line of SQL - is it the Source property of the Recordset object? I'm not sure what you mean - I am trying to select records from an Access database that have a first letter that matches the letter on the caption of the sstab1 control. I have MDAC 2.6 installed and can't make a connection. I don't have SQL server set up as I am trying to set this application so a person doesn't have to purchase and install SQL on their computer to use this system. It was my understanding (perhaps incorrect) that SQL queries would be able to be used by anyone as long as the dataset was set up correctly and the MDAC component was installed. Thanks, Jenn jennie_195103-15-2004, 07:14 AMIs your SQL line like this strSQL = "Select * FROM rsaddress WHERE LName = ssTab1.Caption" if so try strSQL = "Select * FROM rsaddress WHERE LName = '" & ssTab1.Caption & "'" NOPE - maybe that is my problem, let me give that a try and see what happens. jennie_195103-15-2004, 07:20 AMNOPE - maybe that is my problem, let me give that a try and see what ha
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 : " & objAccount.Caption Next WScript.quit Guy Recommends: SolarWinds Engineer's Toolset v10 This Engineer's Toolset v10 provides a comprehensive console of 50 utilities for troubleshooting computer problems. Guy says it helps me monitor what's occurr