ChuckA said:
Basically what my boss wants is a seperate report for each vehicle in the database. As its set up now I can produce this report but I have to manually enter each and every vehicle number in the condition parameters I have setup (begindate, enddate, and vehicleid). What I want (and havent figured out how to do) is set it all up so i can remove the vehicle Id part and as the report gets to the next vehicle number in line it automatically starts a new report for that number. Thanks for any help.
Oh boy! This is the second question today that I don't have
a good answer for. It is very difficult (and not especially
reliable) to generate multiple variations of the same report
using code. The OpenReport method will just give the focus
to a report that's already open. The approach of opening
multiple instances of the same report is a tricky affair at
best.
If you are printing the report directly to the printer (not
previewing) then you could use a code loop that checks if
the report is still printing a previous vehicle before
opening it again. Assuming you have some sort of list of
the vehicles, you could loop through the list and issue an
OpenReport (using the WhereCondition argument to specify the
vehicle) then use the SysCmd function to check if the repot
is closed before going around the loop for the next vehicle.
Something like this air code might do it:
For Each vehicle In somecollection
DoCmd.OpenReport "reportname", , ,"VID =" & vehicle
Do
DoEvents
Loop Until SysCmd(acSysCmdGetObjectState, _
acReport, "reportname") = acObjStateOpen
Next vehicle
I hear what you're saying about what the boss wants, but how
can he tell if he gets a pile of separate printouts or a
single printout that contains the same pages???