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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing various Access reports in VBA

Status
Not open for further replies.

MrBaRRon

Programmer
Aug 8, 2003
39
IT
Hi everybody,

I need to print various Access reports (about 6 reports) in VBA.

Does anyone know the function or the syntax to do it ?

Thank U
 
Below is the code off a button to print more than one justput the code with the name of the report below each other
DoCmd.OpenReport "Your Reort name", acViewPreview
DoCmd.OpenReport "Your Reort name",acViewNormal

Hope this helps
Hymn
 
Aaaah !!

Thank U very much and thanks for your interest.

By the way is it possible to insert an auto page number on each page printed ?


 
Yes but their are various reports to print simultaneously and each one doesn't have the same number of page.

If I do like that, for each report printed the page number restart at zero.

But all those reports make one general report.
 
Thinking aloud here
Create a global variable in a module: Public varPage As Variant
Before printing the reports set the variable to 1 then print the reports:
Code:
varPage = 1
DoCmd.OpenReport "Report1", acViewNormal
...
DoCmd.openReport "Report6", acViewNormal
In each Report you need to set the on open event and reportfooter on format event to pick up and put down the page number. you may need to experiment with this a bit
Code:
Private Sub Report_Open(Cancel As Integer)
Me.Page = varPage
End Sub

Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
varPage = Me.Page + 1
End Sub
HTH
Peter
 
Ok. thank U very much but which sub must I call and from which sub, and what is the code I must to link with the button for printing ?

Thank U for your interest !

 
Define the global variable in a module, I don't think it matters which one but it must not be in a sub, it goes under the option explicit or whatever is at the top of the module.
The fist bit of code goes behind your button. open them all in the sequence you want the numbering to go. (opening them in acviewnormal sends them direct to the printer).
The second bit of code needs to go in each report.
Hope this makes sense
Peter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top