Help opening a report to display a group of records

Punice

Registered User.
Local time
Today, 07:40
Joined
May 10, 2010
Messages
135
Access 2007: I have a form with a combobox that is configured as value list. I want to pick a trip number (ie., D_TN) from the list, like trips 1 thru 10, and open a report.

I, also, have a query that contains the leg numbers for each trip, like: 3.01, 3.02, . . . . 3.05., which are all under trip 3, where D_TN = 3.

I already have written afterupdate code that gets the max & min leg numbers after a trip number is selected, which for this example are maxT_TN = 3.05 & minT_TN = 3.01.

I need help with the code that uses those three parameters and opens a report displaying only the records for the selected trip number, 3 for this example.

I know how to do that for date ranges, from Allen Browne's paper, but couldn't get a variation of it to work.
 
Last edited:
Hi. If the value from your list is say a "3", have you tried using Like? For example:
Code:
DoCmd.OpenReport "ReportName", acViewPreview, , "[FieldName] Like '" & Me.ComboboxName & "*'"
Hope it helps...
 
I used theDBGuy's code and it does what I wanted done for single reports. Thanks for you help.
 
Your code did what I wanted. Now, I need to know how to have it do it for a main report and a sub-report, with the code in a form's combobox where an integer that represents a trip number and the main report displays the trip leg records (date, mileage, city, etc.) and the sub-report displays the fueling records (date, gal, vendor, city & state) for the trip. The following works for individual reports, but not for both
In the main report: DoCmd.OpenReport strReport, acViewPreview, , "[T_TN] Like '" & Me.cboBoth_lbl & "*' "
Don't know how to include this: DoCmd.OpenReport strReport, acViewPreview, , "[F_SerNo] Like '"& Me.cboF_SerNo_lbl & " * '".
Currently, only the main report works right; the sub displays all records, because it's now in my sub-routine.
 
Last edited:
Your code did what I wanted. Now, I need to know how to have it do it for a main report and a sub-report, with the code in a form's combobox where an integer that represents a trip number and the main report displays the trip leg records (date, mileage, city, etc.) and the sub-report displays the fueling records (date, gal, vendor, city & state) for the trip. The following works for individual reports, but not for both
In the main report: DoCmd.OpenReport strReport, acViewPreview, , "[T_TN] Like '" & Me.cboBoth_lbl & "*' "
Don't know how to include this: DoCmd.OpenReport strReport, acViewPreview, , "[F_SerNo] Like '"& Me.cboF_SerNo_lbl & " * '".
Currently, only the main report works right; the sub displays all records, because it's now in my sub-routine.
Hi. Can you post a screenshot of your report? If we're talking about a true subreport here, you cannot use the OpenReport method to open it inside a main report. You simply open the main report and make sure the subreport is properly linked to it.
 
on the subreport you add Link Master Fields (PK of main report) and Link Child Fields (FK of subreport).
 

Users who are viewing this thread

Back
Top Bottom