Running a report from a button

TwinHype

New member
Local time
Today, 21:25
Joined
Apr 25, 2006
Messages
5
Hi All,

I have looked around and can't seem to find out how to do this (too basic!). Just have one report that I wish to run of of a button on a form.

Can anyone help?

Thanks

Twin
 
Have you tried enabling the tool wizard? This should do it for you...
 
Use this code as an On Click – event procedure for your command button. You will need to use your command button name and your report name.

Private Sub CommandButtonName_Click()
On Error GoTo Err_CommandButtonName_Click

Dim stDocName As String

stDocName = "YourReportName"
DoCmd.OpenReport stDocName, acPreview

Exit_CommandButtonName_Click:
Exit Sub

Err_CommandButtonName_Click:
MsgBox Err.Description
Resume Exit_CommandButtonName_Click

End Sub


Hope this helps
 
Last edited:
There is a "Buttons" button on the toolbar which will do what you want in a few seconds. Drag the button symbol to where you want it & select your report in the menu (pops up automatically). After that click "next" a few times & you have a command button to your report(created by the wizard). Very easy. You could also do as suggested in the last post here & enter the code yourself. Take your pick. If you are not confident use the wizard.;)
 

Users who are viewing this thread

Back
Top Bottom