problem with printing multiplr copies (1 Viewer)

history

Egyptian Pharaoh
Local time
Today, 08:03
Joined
Jan 26, 2008
Messages
190
I have a problem with printing reports based on date query (the date is placed in a subform on the Mainform).
What I need is to print these reports directly by one command button without showing the reports, under some conditions regarding multiple copies

May be I couldn't explain my case but I will tell in few details :

I have 8 reports :
Report 1 , Report 2 , Report 3 , Report 4 , Report 5 , Report 6 , Report 7 , Report 8
All these reports based on date query, when the user hit the command button it should give prompt box for date to specify the desired date.

First Step
Report 5 , Report 6
will be printed according to the user decision, it should be a message appears to the user asking him if he need to print those reports or not.
If Yes, a prompt box for date will appear to enter the desired date and the reports will be printed and move to the second step
If No, the reports won't be printed and move to the
second step.

Second Step
Report 7 , Report 8
will be printed according to the user decision, it should be a message appears to the user asking him if he need to print those reports or not.
If Yes, a prompt box for date will appear to enter the desired date and the reports will be printed and move to the third step
If No, the reports won't be printed and move to the third step.

Third Step
Report 1 , Report 2 , Report 3 , Report 4
A prompt box for date will appear to enter the desired date and the reports will be printed and finish.

The problem that when I hit the command button it prints just one copy for the first step and then print the form itself until the last record

This is the code I'm using

On Error GoTo Err_Command12_Click
a = MsgBox("Do you want to print Report1 & Report 2?", vbYesNo, "Notification")
If a = vbYes Then
DoCmd.OpenReport "Report1", acViewNormal
DoCmd.PrintOut , , , , 2
DoCmd.OpenReport "Report2", acViewNormal
DoCmd.PrintOut , , , , 1
Else
MsgBox "Ok , the reports will not be printed ! Well Done", vbInformation, "No Print"
End If

e = MsgBox("Do you want to print Report3 & Report 4?", vbYesNo, "Notification")
If e = vbYes Then
DoCmd.OpenReport "Report3", acViewNormal
DoCmd.PrintOut , , , , 2
DoCmd.OpenReport "Report4", acViewNormal
DoCmd.PrintOut , , , , 1
Else
MsgBox "Ok , the reports will not be printed", vbInformation, "No Print"
MsgBox "Wait until the printer finish then organize your reports", vbInformation, "Done"
End If

DoCmd.OpenReport "Report5", acViewNormal
DoCmd.PrintOut , , , , 2
DoCmd.OpenReport "Report6", acViewNormal
DoCmd.PrintOut , , , , 2
DoCmd.OpenReport "Report7", acViewNormal
DoCmd.PrintOut , , , , 1
DoCmd.OpenReport "Report8", acViewNormal
DoCmd.PrintOut , , , , 1

Exit_Command12_Click:
Exit Sub

Err_Command12_Click:
MsgBox Err.Description
Resume Exit_Command12_Click

I'm waiting your help

Thank you in advance
 

vbaInet

AWF VIP
Local time
Today, 06:03
Joined
Jan 22, 2010
Messages
26,374
Let me just mention two things:

1. Use acViewPreview instead of acViewNormal
2. When you open a report and before printing use Docmd.SelectObject to the select the report you just opened. This will ensure the focus is on the report you want to print.
 

history

Egyptian Pharaoh
Local time
Today, 08:03
Joined
Jan 26, 2008
Messages
190
Thanks a lot for your help
but I couldn't get the point
 

vbaInet

AWF VIP
Local time
Today, 06:03
Joined
Jan 22, 2010
Messages
26,374
Look into SelectObject and read about what it does. Check the help files (for example)
 

history

Egyptian Pharaoh
Local time
Today, 08:03
Joined
Jan 26, 2008
Messages
190
Thanks for trying help
I thought that I could have any additions to my code
anyhow thanks again,
I'll try to look into this subject more and more

see you
 

vbaInet

AWF VIP
Local time
Today, 06:03
Joined
Jan 22, 2010
Messages
26,374
No addition to your code yet. Just see what that method does. You said it prints your form after the first step, so using SelectObject will ensure that it will print your report when it's selected and not your form.
 

history

Egyptian Pharaoh
Local time
Today, 08:03
Joined
Jan 26, 2008
Messages
190
Thanks a lot my dear brother (vbaInet)

I read about this method "SelectObject"

It's working more than well ,,, thank you very much for your advice
Wish you best life
 

Users who are viewing this thread

Top Bottom