Opening a Report

M

maud.july

Hello,

I'm new to Access and have a very basic question. I want to open a
report when a user clicks a button on a form. Now since I can open a
form through a button click by pasting:
=OpenForms("FormName") in the "On Click" setting in the properties
menu, I would assuming using:
=OpenReport("ReportName")
would be the trick. But it's not. Many of the examples on the net I
have found use lines such as:
docmd.OpenReport "rpt_name", acViewPreview, "",

But when I try this I just get an error saying that the marco docmd
can't be found. In the sample database in Access when I click "Build
Event" on a button that produces a report, I see code of the form:

Private Sub Print_Click()
' Print selected report. This procedure uses the PrintReports
' Sub procedure defined in (General) section of this module.

PrintReports acNormal

End Sub

but when I click on "Buid Event" on the button in my form and try to
past in analogus code (to a screen that looks different compared to
the sample database) it just gives errors and more errors.

Thanks.
 
A

Allan Murphy

Maud

You would have soething like this

sub print_click()
DoCmd.OpenReport "rpt_name", acViewPreview
end sub

NOTE
There is a FULL STOP after DoCmd

rpt_name is the name of your report

AcViewPreview is used to Preview the Report on the screen before printing

You can use AcViewNormal to prin the report

Allan
 

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