Printing Report/Sub Report

Yeldarb

Registered User.
Local time
Today, 11:09
Joined
Mar 21, 2012
Messages
11
Hi all. I have read from this site many times and am very thankful for the many well written responses to various questions.

Okay, I have a head scratcher. I have a form and a sub-form, linked by EmployeeID, where the sub-form contains multiple records for each employee, for example multiple injuries. The user of the DB would like to print basically a screen-print of the two forms. Since, reports are made for printing instead of forms; I have attempted to transfer the data to a report and print. I have successfully transferred the fields, the correct data, even down to the individual record of multiple records in the sub-form.
My issue is that once the sub-form’s individual record was ‘moved to’ and the program starts to print, the sub-form refreshes back to the first record for that employee and the page printed is the wrong record.
I believe this is because there is more than one request for the form/sub-form to be queried when it is loaded (I hope I explained that correctly).
Question: Is there a ‘single way’ to open a report and sub-report so that the main report shows the correct EmployeeID and the sub-report, which is linked by EmployeeID to the main report, to show the correct individual record? Below is a copy of the code I used that queries the correct record in a ‘double way’.
Ex:
NewID = Forms.frmMain.EmployeeID
DoCmd.Close acForm, "frmMain", acSavePrompt
DoCmd.OpenReport "rptInjuryScreenPrint", acViewReport, , _
"EmployeeID = '" & NewID & "'"
Reports.rptInjuryScreenPrint.[tblInjury subform].SetFocus
DoCmd.GoToRecord , , acGoTo, RecordNumber
strCurrentPtr = Application.Printer.DeviceName
Set Application.Printer = Application.Printers(strCurrentPtr)
DoCmd.PrintOut acPages = 1, 1, 1, , 1
 

Users who are viewing this thread

Back
Top Bottom