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

open a report based on maximum value in a query

Status
Not open for further replies.

cin2mike

Programmer
Jul 24, 2003
3
US
What I have is a form with combo boxes that sets parameters in a query. After the query runs I then want to open a specific report based on the maximum value in one of the fields. There are about 10 different reports based off the same query but I can't get it to go to the right report.
 
Hi,

You can use something like this in your code:

DoCmd.OpenReport "Reportname", acViewPreview, WhereCondition := "Field=" & Max (Fieldname)

or a reference to your form if you want it to come from there.

John
 
Which part are you having problems with? There's a few ways to do this, but this is what first came to my mind: After the parameters are selected I'm assuming you run some code to run the query...keep this, but make it a Make-Table query. Then use the DMax function to grab the max value. Then use a Select Case statement to determine which report to open. Let me know what you need help with...hope that helps.

Kevin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top