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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report based on parameter query

Status
Not open for further replies.

krankyboy

Programmer
May 27, 2003
4
IN
Hi,

I have a query that I want to run a report off of. I've defined two parameters of date/time type, [stDate] and [enDate]. These two parameters are then used in 6 columns of the query.

Can I just use the Where clause in the Docmd object such as
[stDate] = some value in my textbox,
[enDate] = " " to populate the parameters correctly?

Thanks,

A


 
krankyboy
Try something such as
DoCmd.OpenReport YourReportName, acPreview, , "[stDate] = '" & Me.YourTextBox & "'"

Tom
 
Six different date columns sounds a bit un-normalized. My approach would be similar to Tom. I try to remove ALL dynamic criteria from report record sources. Build them into a where clause as Tom suggests. Dates need to be delimited with "#" so your where clause might be:
Code:
Dim strWhere as String
strWhere = "[DateFieldA] Between #" & Me.txtStDate & "# AND #" & _
    Me.txtEnDate & "# "
DoCmd.OpenReport YourReportName, acPreview, , strWhere

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top