Print all Tabs of a Report Created from a Form

F

flores

I created a form that uses a tab control to display two full pages. Page1
and Page2 are the tab's names (index 0 and 1). The two pages are bound to a
single table called tblComplaints. Each page was designed to fit on an 8.5"
by 11" page and to print as seen on the screen. Then I saved the form as
REPORT called rptComplaints. The report looks exactly as the form, it has
two pages (two tabs) and each page fits on one page.

I am sharing the code I wrote to print the rptComplaints. The code is
called from a command button on frmComplaints. It creates a filter to show
only one record based on control ComplaintNo from frmComplaints. Then the
report is sent to the printer. The problem is that it prints only Page1
(index 0), and page2 (index 1) is not printed.

Can someone tell me what code I should use to print both pages of the
report’s Tab Control (call it tabCtrl)?

This is the code that prints the report, but it prints only page1:

Private Sub cmdPrintComplaint_Click()
'
Dim ReportName$
Dim rprt As Access.Report, ReportObj As Object
Dim dbs As Object

ReportName$ = "rptComplaints"
Set dbs = Application.CurrentProject
Set ReportObj = dbs.AllReports.Item(ReportName$) ' to use IsLoaded

On Error GoTo Err_Handler
WhereClause$ =
"([tblComplaints]![ComplaintNo]=Forms!frmComplaints!ComplaintNo)" '&
Forms!frmComplaints!ComplaintNo & ")"
If ReportObj.IsLoaded Then 'Close report if it is already open
DoCmd.Close acReport, ReportName$, acSaveNo
End If

DoCmd.OpenReport ReportName$, acViewNormal, , WhereClause$ ' This prints
the report without previewing.
Set rprt = Reports(ReportName$)

DoCmd.SelectObject acReport, ReportName$, False
rprt.ZoomControl = 90 ' set view to 90 percent zoom

Exit_Proc:
Set dbs = Nothing
Set ReportObj = Nothing
Set rprt = Nothing
Exit Sub

Err_Handler:
If Err.Number = 2501 Then ' Canceled operation, report has no data.
Me.SetFocus ' return to input form, maximized.
End If
Resume Exit_Proc

End Sub
 
J

John Spencer

As far as I know, you cannot print TABS on a report. What you would need to
do is take the controls off the tabs and distribute them over two pages.

You should be able to select all the controls on tab (page1) and then cut them
and paste them onto a blank area of the report. Repeat for page 2.

Delete the tab control and arrange the controls Page1 on top, page 2 on
bottom. If needed you can insert a page break control (it's on the toolbar
near the bottom) to force a page break between the controls for page 1 and the
controls for page 2.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 

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