search using a listbox

  • Thread starter Thread starter Guest
  • Start date Start date
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!
 
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] & " ' "
 
Back
Top