Print Form - from command button

P

Pele

Question 1
I have used the command button wizard to create a button on a form. The
intention is to use that button to print a specific form regardless of which
form the button is attached to. Unfortunately, when the button is clicked, it
always prints off the form on which the button was attached to as opposed to
the form indicated in the code below.

So, what code should I use that will allow a command button to print a
specific form regardless of where the command button was pressed.

Thanks for your help.

Pele



Private Sub Form_Printer_Click()
On Error GoTo Err_Form_Printer_Click

Dim stDocName As String
Dim MyForm As Form

stDocName = "Frm_View Schedule Tbl"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.Name, False

Exit_Form_Printer_Click:
Exit Sub

Err_Form_Printer_Click:
MsgBox Err.Description
Resume Exit_Form_Printer_Click

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top