Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access VBA Syntax Error 1

Status
Not open for further replies.

renigar

Technical User
Jan 25, 2002
111
US
I'm sure this is easy but I've been staring at it for to long. I get the following error message in this line of code.
Error.JPG
DoCmd.OpenReport "Evaluation Due Dates R", acViewNormal, , "Division = " & rs.Fields("Division"), acHidden

Can somebody open my eyes.
Thanks
 
Try "Division ='" & rs.Fields("Division") & "'"
rather than
"Division = " & rs.Fields("Division")
 
I think jedraw is correct.
"Division = '" & rs.Fields("Division") & "'"
Adding single quotes around rs.Fields("Division") ensures the value is treated as a text string in the SQL filter.
 
Thanks jedraw,
That did the trick. I don't think I would have got that on my own.
 
I would suggest this approach, so you can see what's going on:

Code:
Dim strWhere As String
...
strWhere = "Division = '" & rs.Fields("Division") & "'"
Debug.Print strWhere
DoCmd.OpenReport "Evaluation Due Dates R", acViewNormal, , strWhere, acHidden
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top