A
April Slater via AccessMonster.com
Hi Everyone,
This is stupid, but I'm not very good at syntax. I have a form used to set
a filter to print reports. There are three sets of criteria to choose
from. I want the report to preview based on the criteria chosen and I
almost have it right, but I have a syntax error in the code (although I can
see that it will pull the correct information at this point) Please help
me correct the syntax so I can move on with my life
Here is my current code:
Private Sub Preview_Click()
On Error GoTo Err_Preview_Click
Dim strWhere As String
strWhere = "[Type of Contract] = " & Forms![Create Report]![Contract] &
Chr(34) & " And [Discipline] = " & Chr(34) & Forms![Create Report]!
[Discipline] & Chr(34) & " And [Project Name] = " & Chr(34) & Forms![Create
Report]![ProjectName] & Chr(34)
DoCmd.OpenReport "Lessons Learned", acPreview, , strWhere
Exit_Preview_Click:
Exit Sub
Err_Preview_Click:
MsgBox Err.Description
Resume Exit_Preview_Click
End Sub
The error states: Syntax error (missing operator) in query expression '(
[type of Contract]=EPIC" And [Discipline]="Hull" And [Project Name]
="Independence")'.
EPIC, Hull and Independence are the entries in the Combo box chosen by the
user.
Help Please!
This is stupid, but I'm not very good at syntax. I have a form used to set
a filter to print reports. There are three sets of criteria to choose
from. I want the report to preview based on the criteria chosen and I
almost have it right, but I have a syntax error in the code (although I can
see that it will pull the correct information at this point) Please help
me correct the syntax so I can move on with my life
Here is my current code:
Private Sub Preview_Click()
On Error GoTo Err_Preview_Click
Dim strWhere As String
strWhere = "[Type of Contract] = " & Forms![Create Report]![Contract] &
Chr(34) & " And [Discipline] = " & Chr(34) & Forms![Create Report]!
[Discipline] & Chr(34) & " And [Project Name] = " & Chr(34) & Forms![Create
Report]![ProjectName] & Chr(34)
DoCmd.OpenReport "Lessons Learned", acPreview, , strWhere
Exit_Preview_Click:
Exit Sub
Err_Preview_Click:
MsgBox Err.Description
Resume Exit_Preview_Click
End Sub
The error states: Syntax error (missing operator) in query expression '(
[type of Contract]=EPIC" And [Discipline]="Hull" And [Project Name]
="Independence")'.
EPIC, Hull and Independence are the entries in the Combo box chosen by the
user.
Help Please!