Here are the steps the user of the db needs to take to get the report to display the correct employee information:
1. Select Employee from the Switchboard to open the form that displays employee information.
2. On that form the user clicks a button that opens another form for data entry of employee payments through the subform on this form.
3. On this Employee Payment form, the user clicks a button to open the report that contains the subreport. The main report displays general info about the employee and the subreport shows the payment details for that employee.
The record source changes on the fly, depending on which employee was selected in the first place. I am storing the index value in a global variable.
What I am trying to do with my report is basically the same as I have done with my form that contains the subform. I was able to change the recordsource of the subform on the fly as follows:
Form_sfrmMain.RecordSource = "SELECT * FROM tbl_LTDReturnToWorkRecord WHERE Index = " & intLTDIndex & _
" ORDER BY tbl_LTDReturnToWorkRecord.WeekEndingDate ASC;"
The subform on the mainform displays the correct records. I tried the same for the report and subreport, but as you see, it doesn't work.
WHILE WRITING THIS...I HAD ONE OTHER THOUGHT, I TRIED IT AND IT WORKS:
I set the recordsource for the On_Open Event of the Subreport instead of the Main Report. Not sure why it doesn't work the same way for the report as it does for the form.
Here is the code that worked on the On_Open Event of the subreport:
Report_srptSubReport.RecordSource = "SELECT * FROM tbl_LTDReturnToWorkRecord WHERE Index = " & intLTDIndex & _
" ORDER BY tbl_LTDReturnToWorkRecord.WeekEndingDate ASC;"
Thanks so much for your help, Ken!!
