Form for inputing criteria for a report's query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a report that is based on a query. The criteria for the start date
changes and I want a form where I can input the date range (Between
#2/2/2006# and #2/4/2006#) each time the report is run. Is there a way to set
up the form so that the forms asks for the user to put in the start date and
the end date and then put those results in the format above into my query to
run the report correctly?

Thanks,
Robert
 
ryonker said:
I have a report that is based on a query. The criteria for the start date
changes and I want a form where I can input the date range (Between
#2/2/2006# and #2/4/2006#) each time the report is run. Is there a way to set
up the form so that the forms asks for the user to put in the start date and
the end date and then put those results in the format above into my query to
run the report correctly?


Add text boxes (named txtStart and txtEnd) to the form that
opens the report.

Then use code along these line in the command button that
opens the report:

Dim stWhere As String
stWhere = "datefield>=" & Format(txtStart, "\#yyyy-m-d\#") _
& " And datefield<=" & Format(txtEnd, "\#yyyy-m-d\#")
DoCmd.OpenReport "reportname", acViewPreview, , stWhere
 
Back
Top