Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OpenReport 1

Status
Not open for further replies.

woodywoodpecker

Technical User
Oct 23, 2002
9
0
0
US
Hello. I am new to Access so hopefully this is an easy one for you experts. I have a Form that has a Reports Dialog Box called "ReportsList". On the form I have a Print Preview button and a Close button. The Print Preview button will open in Print Preview whichever report in this list is selected. I need to have a button that will Print whichever report is selected and cannot figure out how? If "Print()" in the On Click option Access errors because no report name is identified. Thx.
 
You should verify a report was selected first then open the report in preview mode.

if isnull(me.ReportsList) then
MsgBox "Please select a report"
me.ReportsList.setfocus
Exit Sub
end if

Docmd.Openreport me.ReportsList, acViewPreview
 
Thanks. Once I verify the report is Selected and Opened in Preview Mode will I be able to Print it? Also, are the commands you listed two separate commands or do they get set up together? Sorry if these ?s seem dumb, still trying to learn.
 
The commands are together. They should be used in the On_Click event of the Print Preview button.

You should be able to print the report from the File - Print menu selection. If you have created your own menus and toolbars, then you can add the print command to the menu or toolbar.
 
That worked, outstanding. I have one last concern. Since I am trying to protect the db I removed all the checkboxes for Startup...I think this caused the Print option to be removed from the File menu after the code runs. Is there a way to do the same thing but have the selected document automatically print without having to recheck the checkboxes? We don't want users to be able to Delete Records, Reports, etc.
 
A simple way to fix the Print or Preview choice is to put a second button on the form to Print. Put this code in the On_Click event:

if isnull(me.ReportsList) then
MsgBox "Please select a report to print"
me.ReportsList.setfocus
Exit Sub
end if

Docmd.Openreport me.ReportsList, acViewNormal

This will automatically send the report to the printer, without seeing a Preview of it.

If this is not good enough, you will need to create your own toolbar and add the print button to it.
 
That is good enough and is exactly what I was looking for. Thanks mucho for your help and patience.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top