Form for inputing criteria for a report's query

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
 
M

Marshall Barton

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
 

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