I have written the following code;
I have a combo box in a form which when I choose a name form the list, I want to open a report for that chosen person. I did this before on a simple report and tried to replicate for this report, but this report contains several subreports which all contain the primary key EMP_UID, but now when I run the same code that worked on the simple report all of my reports open not the report for the name I have chosen in my combo box.
Although the message box displays the EMP_UID for the person I have chosen, so I've picked it out from the form I just can't seem to refer to it when opening the form.
Can anyone tell me what I'm doing wrong?
Thankyou.
Private Sub Combo54_Change()
On Error GoTo Err_Command54_Click
Dim stDocName As String
Dim CurrentEmp As String
CurrentEmp = [Forms]![frm_Reports]![Combo54]
MsgBox CurrentEmp
DoCmd.GoToControl "EMP_UID1"
DoCmd.FindRecord CurrentEmp, acAnywhere, False, , , acAll, True
stDocName = "rpt1_EmployeeOuput"
DoCmd.OpenReport stDocName, acPreview
Exit_Command54_Click:
Exit Sub
Err_Command54_Click:
MsgBox Err.Description
Resume Exit_Command54_Click
End Sub
I have a combo box in a form which when I choose a name form the list, I want to open a report for that chosen person. I did this before on a simple report and tried to replicate for this report, but this report contains several subreports which all contain the primary key EMP_UID, but now when I run the same code that worked on the simple report all of my reports open not the report for the name I have chosen in my combo box.
Although the message box displays the EMP_UID for the person I have chosen, so I've picked it out from the form I just can't seem to refer to it when opening the form.
Can anyone tell me what I'm doing wrong?
Thankyou.
Private Sub Combo54_Change()
On Error GoTo Err_Command54_Click
Dim stDocName As String
Dim CurrentEmp As String
CurrentEmp = [Forms]![frm_Reports]![Combo54]
MsgBox CurrentEmp
DoCmd.GoToControl "EMP_UID1"
DoCmd.FindRecord CurrentEmp, acAnywhere, False, , , acAll, True
stDocName = "rpt1_EmployeeOuput"
DoCmd.OpenReport stDocName, acPreview
Exit_Command54_Click:
Exit Sub
Err_Command54_Click:
MsgBox Err.Description
Resume Exit_Command54_Click
End Sub