Access 2007 - prints form instead of report

MartyL354

MartyL
Local time
Today, 16:04
Joined
Jan 12, 2009
Messages
14
I have a form where I prompt the user for criteria. When they click a button I bring up a Report (in Print Preview mode) which uses the criteria. The Report displays properly in the Preview and it is populated correctly. However, Access prints a screen shot of the Form that called the Report instead of the Report.

I use the following Code:
DoCmd.OpenReport ReportName:="rptTaxation", _
View:=acViewPreview

If I change the code and use:
DoCmd.OpenReport ReportName:="rptTaxation", _
View:=acViewReport
it seems to work fine.

What is also rather strange is I have 4 different sections on the Form. Each of those sections prompts for criteria and then opens a Report. Using the same code with "View:=acViewPreview" the other three work fine.

I would prefer to use the Print Preview. This is an application where the users only get the runtime version and it looks a bit nicer (I think anyway) to display the options they get in Preview.

At least I found a way to make it work but I would like to understand why this is happening.

Thanks kindly.
 
How are you printing when you use the acViewPreview? from the default toolbar command? Or do you have a button on your form?

It looks like somehow the the form is the active object, instead of the report.
 
Sorry it took me so long to get back. I was working on another project.

In relation to the post to use "acPreview" that isn't an available option in Access 2007. I am guessing that was a VBA constant in an earlier version perhaps?

In relation to how I was printing I was using the standard Access toolbar (no button on my report). Presuming that is what is causing the issue (with the calling form being the active object) is there a way in VBA to insure that the Report is the active object?

Thanks kindly all.
 
surely once the form is open in preview mode, it is just another object isnt it - so if you have other code running in your calling form, AFTER the docmd.openreport it may well return control to the calling form - perhaps thats whats happening

if you right click the preview, and print from that , then there definitely shouldnt be any issues
 
In relation to the post to use "acPreview" that isn't an available option in Access 2007. I am guessing that was a VBA constant in an earlier version perhaps?

Actually, it does - I might have led you astray but now looking into some of my coding in 2007 because I use two different methods of calling reports - each work.

One method is where I apply a filter to the OpenReport method.

Code:
DoCmd.OpenReport sDocName, acPreview, , sFilter

The other method is if I am just calling a report ...

Code:
DoCmd.OpenReport sDocName, acViewPreview

In the second one, I have used acViewPreview. I can tell that my first method is a copy and paste job from '03 versions and since it worked, I never modified it.

I can't test it now because this particular project is a little jacked up but before I hosed it (in another area of the db) I know it did work.

-dK
 

Users who are viewing this thread

Back
Top Bottom