1
votes

I have a form with a button and I put VBA code into the on click event.

DoCmd.OpenReport."FormName"

When I save and click the button, I expect it to open the report, but it prints the report to my default printer, never opens it.

I can't find out why it's printing instead of opening. Eventually I'd like to have the form filter based on a combo box, but right now I can't even get it to open.

1
Reports are for printing. If you want to see the preview, you have to use the correct argument in OpenReport. See Help (press F1 on OpenReport in your code).ComputerVersteher
ugh - yep that was the issue. ThanksJordy

1 Answers

1
votes

To open up a report in report view, you have to specify the second argument. The default is to print the report directly to the printer.

To open it in report view:

DoCmd.OpenReport "FormName", acViewReport

Or print preview:

DoCmd.OpenReport "TestTable", acViewPreview