Compile Error

G

Guest

I have the above error on the word "Open"?

Private Sub Command16_Click()
Dim qdfCurr As DAO.QueryDef
Dim strPrompt As String
Dim strSQL As String
Dim Crei As String
'Input the random number of Year you want access
'by changeing the Step1_Member_Status query
strPrompt = InputBox("Enter Year in YYYY format.", "Required Data")

If Len(strPrompt) > 0 Then
If IsNumeric(strPrompt) Then
strSQL = "select * from Requests " & _
"where Year([Submit_Date])=" & strPrompt & " AND [Assigned Team
Member] in ("Open", "Closed")"


Set qdfCurr = CurrentDb().QueryDefs("Step1_Member_Status")
qdfCurr.SQL = strSQL
End If
End If

If Check_Records Then
DoCmd.OpenReport "Step1_Status_Summary", acViewPreview
Else
MsgBox "There are no records to view", vbOK, "Error"
End If
End Sub
 
J

Jeff Boyce

Max

What happens if you "lift" that SQL statement out of code and use it to
build a query in query design view? Does it work there?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
T

Tom Lake

You might need to double up on the quotation marks as below:
"where Year([Submit_Date])=" & strPrompt & " AND [Assigned
Team
Member] in (""Open"", ""Closed"")"

Tom Lake
 
G

Guest

"where Year([Submit_Date])=" & strPrompt & " AND [Status] in ('Open',
'HOLD','IN-PROCESS','UNDER-REVIEW')"

Tom Lake said:
You might need to double up on the quotation marks as below:
"where Year([Submit_Date])=" & strPrompt & " AND [Assigned
Team
Member] in (""Open"", ""Closed"")"

Tom Lake
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Use Input Box Value as Creteria 4
Format Date 4
Code Help 2
Import Excel sheets to Access 2
Recordset 5
data access page search code 1
Filesearch 4
Using Find as lookup method goes to semi endless loop 10

Top