I have a problem with printing a Subform. On main form I have some data and 5 subforms. I want to print 1 subform. I created a form with button to print and inserted it to a mainform. When I press the print button it tries to print all the data in the table. I tried to do this:
I can't figure it out what is wrong.
Code:
Private Sub Command5_Click()
On Error GoTo Err_Command5_Click
Dim stDocName As String
Dim MyForm As Form
stDocName = "Form1"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.Name, False
Exit_Command5_Click:
Exit Sub
Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click
End Sub