search using a listbox

G

Guest

I am having a problem with the following code

DocName = "Monthly Employee Tracking"

DoCmd.OpenReport DocName, acPreview, , "[Months]=" & Forms![Search Monthly
Employee]![List4]

DocName is the name of the report, infor in the listbox(list4) is coming
from a qry, months is dervived from [trackdate]----Format$([TrackDate],"mmmm
yyyy",0,0). What I would like to do is to click on the month and it should
be able to poen the report with that month.

with the above code, I am having a run time error----- syntax error(missing
operator)n in query expression([Months]=May 2005)


Please help!
 
D

Douglas J. Steele

You have to put quotes around text strings:

DoCmd.OpenReport DocName, acPreview, , "[Months]='" & Forms![Search Monthly
Employee]![List4] & "'"

Exagerated for clarity, that's

DoCmd.OpenReport DocName, acPreview, , "[Months]=' " & Forms![Search Monthly
Employee]![List4] & " ' "
 

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

Top