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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print Options Question 1

Status
Not open for further replies.

random75

Technical User
Apr 16, 2008
34
US
I have a an application which does not ever have any toolbars showing. All menu options are generated with form menus and command buttons. I have a Reports menu that shows a list of reports with a command button to print the report. As soon as the command button is clicked the report immediately prints to the default printer even though I have the report configured in Page Layout to print to a 'specific printer'. No print selection window comes up. How can I maintain my command button approach (no toolbars), but have the print options window appear to allow for printer choice or cancel rather than having the report automatically dump to the default printer with no prompting. Thanks in advance for any help!
 
You need to add
DoCmd.RunCommand acCmdPrint

To your code, I think.
 
Remou:

Your post helped provide some alternatives. My report is printing using the OpenReport method and if I run that method under acPreview with your DoCmd statement following I see the report form on the screen with a modal Print Selection window above. Unfortunately, the report form is blank at this point. No data is seen. Once I click print, the data flies on the screen and the report prints to the printer. But I really haven't had an opportunity to preview the report before deciding whether to print. What would be a perfect solution would be for the report to print to the screen for previewing and then allow for a right click context menu from the preview to provide the print selection options. Any idea how to do that?
 
You can add the print command to a custom shortcut menu. Type "Create a custom shortcut menu for the current Access database or Access project" into help or press F1 in the shortcut menu property of the report's property sheet for more information.
 
Remou... Thanks for your posts. I have been experimenting with the shortcuts and they have been helpful, but I am now taking a little different approach. My report uses a parameter query to specify a date range. When I request the report, a modal form appears that has 2 options, 'Preview Report' and 'Print Report'. It works pretty well but I don't like the fact that I have to rekey the dates between previewing and printing. I preview the report and if I like what I see, then I hit the print report button and I have to key in the dates again. Is it possible to capture the parameter values to variables during the preview routine and then apply the variables to the printing of the report so that the dates do not have to be keyed in a second time? I'm not sure how to capture those query parameter values or if I should just take a different approach and impose a filter on the report using variables representing the beginning and ending date for the report. Can that be done? What do you think?
 
I hate to keep asking questions, but another thought that crossed my mind was creating a recordset with the where clause expressing the beginning and ending dates from the original table and then printing the report from the recordset data. Is that possible?
 
Both these solutions are possible, but what is usually recommended is to use a form to get the parameters. As you are already using a modal form, it would be a good place to add the date boxes. This will also allow you to reference a calendar or calendar control (however, be wary of ActiveX controls). The query that the report is based on would then reference the form on the criteria line, under the relevant field:

[tt]=Forms!frmDates!txtStartDate[/tt]

Or

[tt]Between Forms!frmDates!txtStartDate And Forms!frmDates!txtEndDate[/tt]

Rather than close the form, you would set the visible property to false in the click events of the various report view options. The form can stay hidden in background rather than closed, for the most part, meaning that the same dates will be available to the user whenever the form is shown.
 
Well, I've set all this up. I included preview and print commands in my range selection form and had my reports form close rather than stay in the background. The modal form is actually open all the time at this point until I close it (after finishing printing) and then the reports menu comes back. For some reason, even though I have specified the form controls in the parameter query, I am still getting date prompts when I preview or print the report. I must be missing something! Unfortunately i don't have any actual data in my application right now (I was going to test the integrity of the date range aspect of this later), but I shouldn't be getting any prompts, should I? What could be causing this? I'm tempted to put a literal date in the parameter query and see if I still get prompts. Thanks for your help!
 
Remou... As an update to my last post when I execute the query directly, I get 2 sets of prompts, and the second set of prompts if for my form parameters (which makes sense since the form is not open). So the form parameters are being interpreted properly from my selection form. I don't understand why the original prompts haven't gone away? There are only 2 entries in the query. The all fields indicator which is marked show and the criteria field (DateTransferred) with show unchecked. I can't seem to figure out what I am missing.
 
Just to be clear. Is the form open, as it must be, when you run the report? Have you ensured that the record source of the report points to the query?
 
I found the problem. When I open the query in Design mode, under the query file option up top, there is a parameters option and the beginning and ending date are specified there as well as in the form. I deleted them and I am no longer getting prompts. Now I'll test the date range integrity of my form's range setup. Thanks for all your help and guidance!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top