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

Print Report with Macro

Status
Not open for further replies.

mibeach7

MIS
Jun 18, 2003
35
US

Greetings,
I have 4 reports with VBA code behind them that checks boxes on each report based on a table value for each row.
I am able to pull up each report manually and print to the printer.

The problem:
I added the 4 reports to a macro to open report and print.
Then added a button to a form to run the macro.
The macro doesn't print the reports, it opens a print dialog box and appears to send a job to the printer for each report. But nothing actually prints.

Here is the embedded code for one of the reports. As stated, this code works when the reports are pulled manually.
Option Compare Database

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
' TYPE_CODE B1
Set current_report = Application.Reports(Application.CurrentObjectName)
With current_report
strArr = Split(!txtDenials, "|")

'!Check4.Visible = False
!Check5.Visible = False
!Check6.Visible = False
!Check7.Visible = False
!Check77.Visible = False
!Check9.Visible = False
!Check11.Visible = False
!Check13.Visible = False
!Check165.Visible = False
For i = 0 To UBound(strArr) - 1

Select Case strArr(i)
Case "004"
!Check165.Visible = True
Case "005"
!Check5.Visible = True
Case "006"
!Check6.Visible = True
Case "007"
!Check7.Visible = True
!Check77.Visible = True
Case "009"
!Check9.Visible = True
Case "011"
!Check11.Visible = True
Case "013"
!Check13.Visible = True
Case "015"
!Check6.Visible = True
Case "165"
!Check165.Visible = True
Case Else

End Select
Next i
End With

End Sub


Private Sub Report_NoData(Cancel As Integer)
Cancel = True
End Sub

+++++++++++++++++++++++++++++++

Any help would be appreciated, thanks alot!
 
Hi, I don't do much with macros, but you could try something like this behind you print button:

Private Sub Command0_Click()
DoCmd.OpenReport "Report1", acViewNormal
DoCmd.OpenReport "Report2", acViewNormal
DoCmd.OpenReport "Report3", acViewNormal
DoCmd.OpenReport "Report4", acViewNormal
End Sub

Hope that helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top