473,385 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

print open report via print button on the switchboard

3
I've created a database in Access 2003 with multiple reports that are accessable from the switchboard. The switchboard also has a print button. The user selects the report from the menu which then opens in another window for the user to preview. I am trying to enable the print button to print the open report however the print macro prints the switchboard instead.

Can anyone provide me with the code needed to accomplish my goal? I have no experience with VBA and little with SQL. My users are not versed in Access so I'd like to make things as simple as possible for them.

Thank you for your time and any help you can provide.
Mar 30 '09 #1
4 4475
DonRayner
489 Expert 256MB
Set the focus to the report before you do the print command. Replace MyListBox with whatever the name of your listbox is.

Expand|Select|Wrap|Line Numbers
  1. Dim ReportName as string
  2. ReportName = Me.MyListBox
  3. DoCmd.SelectObject acReport, ReportName, False
  4. DoCmd.PrintOutut
  5.  
You will also need to either add some code to check if the report is open or code to trap the error that will be generated if the report is not open.
Mar 30 '09 #2
pacarv
3
Thank you very much for your quick response. Unfortunately I'm not using a ListBox; I've set everything up to be accessable from buttons on the switchboard. For instance... clicking on the Category Reports button opens another switchboard that lists each report for individual categories. The report opens in another window, its this window I want to print from the print button on the switchboard. Does that make sense?

Should I be using a ListBox instead of the way I've explained?
Mar 30 '09 #3
DonRayner
489 Expert 256MB
Then you are going to have to set a form global variable with the report name when the user clicks on the report to run. Instead of declaring the variable in the private sub, you declare it at the top of the form module right after the "OPTION COMPARE DATABASE" this way it's available as long as your form is open.

In the private sub for each button just before you open the report for preview, you can set the variable to the report name.

So as in my example above Line 1 would go to the top of the module, line 2 would go into the sub for each preview button and the remainder would go into the sub for your print button.
Mar 31 '09 #4
pacarv
3
Thank you again for your help, I'll give it a try and see how it goes.
Mar 31 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Terry | last post by:
I have created a Main Switchboard in Access 2000 and it has a button which opens a Form. I have set the form Properties Default View to Datasheet and this always opens in datasheet view. When I...
4
by: Jan | last post by:
I am having problems trying to print a report based on a form. This is a search form only, no data input. There is a query that the form looks at, but then there are numerous comboxes that you...
0
by: Ace Calhoon | last post by:
Has anyone encountered this before? When a report is opened by my switchboard (i.e. either directly, or through code run by the switchboard), a crash occurs when changing print settings. So...
3
by: Mariame | last post by:
Hi All, How to add a print button to a crystal report??? Thx & Regards
2
by: Miguel | last post by:
I have reviewed the many postings on this topic and understand the principle, but am not sure where in my case to apply trapping an error. I have created a form to supply parameters to a report. I...
9
by: mtgrizzly52 | last post by:
Hi all, I've looked for an answer for this in lots of books, online in several discussion groups and have not found the answer which I feel may be very simple. What I want to do is have a...
2
by: airdata | last post by:
Hi I currently have the following code attached to a command button on a switchboard form. This is basic Access 2000. Private Sub Print_daily_reports_button_Click() On Error GoTo NoData...
1
by: Scott | last post by:
Hello- I have a contol button on a form that I want to code to open a report (rptReviews), then display the print dialogue box so that users can select a printer. This report needs color, but...
12
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.