Help converting OpenReport macro to VBA?

gojets1721

Registered User.
Local time
Today, 13:25
Joined
Jun 11, 2019
Messages
430
I've got a button in a form to open a report and its using a macro, but I'd like to convert it to VBA if possible. I'm just not sure how.

It's an OpenReport macro where the condition is "[qryComplaints]![CustomerAccount]=[Forms]![frmComplaints]![CustomerAccount]. The report name is "rptSearchCustomerAccount". The report's source is qryComplaints.

Any idea?
 
  1. Open the form in design view and select the buttons OnClick event that runs the macro
  2. Change the Event from a Macro to an [Event Procedure]
  3. Click the ... option to the right which opens a VBA window
  4. Enter the following all one one line:
DoCmd.OpenReport "rptSearchCustomerAccount", acViewPreview, ,"[CustomerAccount]=[Forms]![frmComplaints]![CustomerAccount]" , acWindowNormal

So now when the button is clicked, it will run the VBA code entered instead of a macro.
 
  1. Open the form in design view and select the buttons OnClick event that runs the macro
  2. Change the Event from a Macro to an [Event Procedure]
  3. Click the ... option to the right which opens a VBA window
  4. Enter the following all one one line:
DoCmd.OpenReport "rptSearchCustomerAccount", acViewPreview, ,"[CustomerAccount]=[Forms]![frmComplaints]![CustomerAccount]" , acWindowNormal

So now when the button is clicked, it will run the VBA code entered instead of a macro.
This worked!

The only small issue is that it opens the report in a print preview mode. Is it possible to just open up normal? I ask because the normal view allows you to scroll through the report, whereas the print preview makes you change pages. Just a bit simpler. Thanks!
 
This worked!

The only small issue is that it opens the report in a print preview mode. Is it possible to just open up normal? I ask because the normal view allows you to scroll through the report, whereas the print preview makes you change pages. Just a bit simpler. Thanks!
Look up the command :(
The option of how it is opened is quite evident?
Or use @Pat Hartman's option?
 
Keep in mind that pagination code does not run when you open the report in Report View.


Too late once the embedded macro is deleted.
Ah, well, some very simple research then?
 

Users who are viewing this thread

Back
Top Bottom