How to print a report with multiple tab controls


J

jollygreen_EMT

I am working on a database with forms and have created a report based on the
form to use for printing. My report has 4 tab controls since the printed
report needs to be 4 separate pages (and would be longer than 22 inches). I
have a command button on the form to use for printing the report. The code
for the command button is:
Private Sub cmdPrint_Click()
Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[CUSTOMER #] = " & Me.[CUSTOMER #]
DoCmd.OpenReport "Rent To Own Contract Report", acViewNormal, ,
strWhere

End If
End Sub

My problem is that only the first tab control prints using this code. I have
tried DoCmd.OpenReport "Rent To Own Contract
Report!InformationSheet",acViewNormal,,strWhere
but I get an error that I have either mispelled the report or there is not
report by that name. Information sheet is the name of one of the tab controls.

What I want is to print all 4 of the tab controls from the report when the
command button is clicked on the form.

Thank you for your help.
 
Ad

Advertisements

A

Albert D. Kallal

You'll not have any great success trying to print that form. so the solution
is to build a report.

You mention that you have 4 tab controls, is there a sub form behind each
tab control on that???

If there's for a sub form behind each tab, then in your report designed
simply drop in four sub-reports with a simular layout.

And the same goes in for some strange reason that the fields behind those
tab controls are in fact from the main table and form, you can still build 4
sub-reports that are based on the same table. Simply then drop these 4
sub-reports into one main report form.

if me.Dirty = true then
me.dirty = false
end if

docmd.OpenReport "name of reports",acViewPreview,,"id = " & me!id

You'll have to replace id with whatever is unique primary key or unique
identifier used to identify the record that you're currently on.

It's not clear if you want the report to print only the same information on
the currently selected tab, or to print all the data behind all of the tabs.
Regardless either way, the above approach will allow you to print this
information in a report.
 

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