Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you print 3 froms using 1 print button?

Status
Not open for further replies.

gandalf1

Programmer
Sep 13, 2001
14
US
I have three forms that I need to print using 1 button on the last form instead of a button on each form. What do I need to change in the code and/or where do I put the names of the other forms so that they print? Here is what I have so far:

Private Sub Print_Click()
On Error GoTo Err_Print_Click

Dim stDocName As String
Dim MyForm As Form

stDocName = "Index Performance Appraisal 1"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.Name, False

Exit_Print_Click:
Exit Sub

Err_Print_Click:
MsgBox Err.Description
Resume Exit_Print_Click


End Sub
 
This will do,

Private Sub Command1_Click()
Dim doc As String

Me.Command1.Visible = False

doc = "Form1"
DoCmd.SelectObject acForm, doc, True
DoCmd.PrintOut

doc = "Form2"
DoCmd.SelectObject acForm, doc, True
DoCmd.PrintOut

doc = "Form3"
DoCmd.SelectObject acForm, doc, True
DoCmd.PrintOut

End Sub
 
Thank you!Is that all I use? I tried it and it didn't print? This is what I have now:
Private Sub Command1_Click()
Dim doc As String

Me.Command1.Visible = False

doc = "Index Performance Appraisal 1"
DoCmd.SelectObject acForm, doc, True
DoCmd.PrintOut

doc = "Index Performance Appraisal 2"
DoCmd.SelectObject acForm, doc, True
DoCmd.PrintOut

doc = "Index Performance Appraisal 3"
DoCmd.SelectObject acForm, doc, True
DoCmd.PrintOut

End Sub
 
Hi,

I've tried myself to have 3 forms, calles Form1, Form2, Form3 (set their HasModule property to Yes so that their names will be recognized in the action).
And it did print all of them in one click.

Take a look again, and let me know if it doesn't work for some reason.

Tin Tin
 
Sorry, please erase the line

me.command1.visible = False

It won't work that way as the button will have to have a focus to print. So you can probably still see the button on the print out result.

 
Thank you again! It is still not printing. I am not sure why. I erased the line me.command1.visible = False. Should I replace it with something?

Thank you,

Justin
 
Justin,

check the form names again. If you type it wrong, it won't give you any error message upon carrying the action, just no print out.
 
If you have rechecked the form names, and nothing wrong.
Just send your applicaton that have the 3 forms and your coding for the button. If your d'base is not too big, you can just zip it and send me that.
 
What is your e-mail address? I will not be able to e-mail you the datbase, but I can send you some screenshots if that will help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top