Command button to run macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Good day,

I have two options.
Print and Preview

I would like to have it so that if one or both are selected they run
different macros. One macro called
View Reports Macros.Preview : On Dbl Click
and
View Reports Macros.Print : On Dbl Click

I would like to have this done through a command button but only to run the
macro that is selected

Any help would be greatly appreciated

Thanks
 
Hi K

Instead of using a macro I think it "may" be better to just use a little bit
of code and use the On-Click or On-DoubleClick. Give it try it may be what
you are looking for.

Change the report-name to what you normally use.


Load this into your On-Click event (to print)

Private Sub CommandButton_Click()
On Error GoTo CommandButton_Click_Err
DoCmd.OpenReport "ReportName", acViewNormal, "", "", acNormal
CommandButton_Click_Exit:
Exit Sub
End Sub

and load this onto your On-DoubleClick event (to preview)

Private Sub CommandButton_DblClick(Cancel As Integer)
On Error GoTo CommandButton_DblClick_Err
DoCmd.OpenReport "ReportName", acViewPreview, "", "", acNormal
CommandButton_DblClick_Exit:
Exit Sub
End Sub


Hope this helps
 
Back
Top