Print forms from vba

Skip Bisconer

Who Me?
Local time
Yesterday, 16:45
Joined
Jan 22, 2008
Messages
285
I have a tab form with 21 reports that I want to print depending on the True/False value of check boxes. I am not very savy with Access VBA. I need to print all the reports daily but this is in the event one or many of the reports need reprinting. I was thinking of using a select case statement instead of a bunch of If statements but I don't understand the Select Case process enough to use it.

I see the docmd.PrintOut which I am assuming is what I should be using but for all my trying I can't seem to get it to work at all. And in reviewing Macros it seems as I can only print to file. I am able to get the report to open, using an if statement and docmd.OpenForm, but what I really want is it to print to my default printer without user input other that clicking the command button.

I obviously don't know how to phrase it. Thanks for looking at my problem.
 
To start with what are trying to print, forms or reports?
 
The check boxes are on a form. If check box value is true then I need to print the report associated with the checkbox.
 
I know there are sleeker ways to do it like with a loop, etc but I'd suggest you simply do a series of IF statements...
 
Skip:

For future reference, I think I would make it easier on yourself by using a listbox which can AUTOMATICALLY list all reports available, so you never need update the controls on the form and you can let it be a multi-select listbox so you can iterate through and print all of the selected reports.

Check out this sample of mine as to the dynamic report list:
http://downloads.btabdevelopment.com/Samples/listbox/SampleSelectReportFromForm.zip

it doesn't currently do multiple reports but it could.
 
If you're printing multiple reports at a time, depending on how complex they are and how much memory your printer has, you may need to add a DoEvents command between each one to keep your code from bombing out.
 
Bob
I am trying to use your example of the listbox control. I have one little problem I don't know how to eliminate. This is your RowSource code adapted to my situation.

SELECT MsysObjects.Name, Mid([Name],5) AS QueryName FROM MsysObjects WHERE (((Left([Name],3))="rpt")) ORDER BY MsysObjects.Name;

All my reports begin with rpt but I have in my database a process to update from the main server that has one object with rpt_ and there never will be a need for the user to review this report. I cannot change the name format as it is essential to the update from server processing. Is there a way to remove this from the list view? I have tried to change the criteria but I can't seem to get it to go away.
 
Just modify the OTHER reports to rept_ and then use:

SELECT MsysObjects.Name, Mid([Name],5) AS QueryName FROM MsysObjects WHERE (((Left([Name],4))="rept")) ORDER BY MsysObjects.Name;
 

Users who are viewing this thread

Back
Top Bottom