Print Command button question...

  • Thread starter Thread starter cathywoodford
  • Start date Start date
C

cathywoodford

Hi. I have a print preview button that is on about 22 forms. I was
wondering is there a way to declare this code globally so that I don't
have to code each one separately. Trick being that each one has to
open with a different report template. For example if the user is on
form1 then when he/she clicks the print button it has to be viewed in
report1, but if they are on form2 and click the button it must be
viewed in report2. Is this possible?

Thanks,
Cathy
 
It won't save you too much code, but you could do something like this:

In a module, put this procedure:

Public Sub PrintPreviewReport(ByVal reportName As String, ByVal filterName
aAs String, ByVal whereCondition As String, ByVal windowMode As acWindowMode,
ByVal openArgs As String)
DoCd.OpenReport reportName, acViewPreview, filterName, whereCondition,
windowMode, openArgs
End Sub

The only thing this saves is having to specify the acView parameter.
However, you can leave out parameters if, for example, you never use the
filterName parameter.

Barry
 
Hi. I have a print preview button that is on about 22 forms. I was
wondering is there a way to declare this code globally so that I don't
have to code each one separately. Trick being that each one has to
open with a different report template. For example if the user is on
form1 then when he/she clicks the print button it has to be viewed in
report1, but if they are on form2 and click the button it must be
viewed in report2. Is this possible?

Thanks,
Cathy

You can, however I don't see much benefit.

Create a New Module.
Sub OpenReports(rptName as String)
DoCmd.OpenReport rptName, acViewPreview
End Sub

Code the command button on each form:
OpenReports "NameOfReportToOpen"
 

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

Back
Top