pop up report in printpreview zoom (1 Viewer)

Wysy

Registered User.
Local time
Yesterday, 23:58
Joined
Jul 5, 2015
Messages
333
Hi,
I have a button to bring up a report in a pop up mode (acDialog). However i need always need to click on the report itself to zoom in. Is there a way to do it via VBA i.e upon opening it zooms itself?
thank you
 

onur_can

Active member
Local time
Yesterday, 23:58
Joined
Oct 4, 2015
Messages
180
Add the following code to the open event of the report
Code:
DoCmd.Maximize
 

Wysy

Registered User.
Local time
Yesterday, 23:58
Joined
Jul 5, 2015
Messages
333
unfortunately it does not work, it keeps the same status.
 

onur_can

Active member
Local time
Yesterday, 23:58
Joined
Oct 4, 2015
Messages
180
try this way (open event)

Code:
DoCmd.OpenReport "report name", acViewPreview
DoCmd.Maximize
DoCmd.RunCommand acCmdZoom100

You can change the value of 100
 

Wysy

Registered User.
Local time
Yesterday, 23:58
Joined
Jul 5, 2015
Messages
333
Fails regardless where i put the code:right after the openreport command or on the open event of the report: command not available
 

onur_can

Active member
Local time
Yesterday, 23:58
Joined
Oct 4, 2015
Messages
180
I'm sorry, I guess I misdirected you with the information I gave. Type the following code on the command button that opens the report on your form and it will be fixed. If you want it to fill the full screen
Code:
Private Sub cmdPreview_Click()
   DoCmd.OpenReport "CounterInformation", acViewPreview
   DoCmd.Maximize
   DoCmd.RunCommand acCmdFitToWindow
   ' DoCmd.RunCommand acCmdZoom150
End Sub


If you want to make the command 150%
Code:
DoCmd.RunCommand acCmdZoom150
you should patch like this.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 14:58
Joined
May 7, 2009
Messages
19,246
you can also add code to the Open Event of the Report itself:

Private Sub Report_Open(Cancel As Integer)
DoCmd.Maximize
End Sub
 

Wysy

Registered User.
Local time
Yesterday, 23:58
Joined
Jul 5, 2015
Messages
333
i have tried the docmd.maximize but it does not work. Report opens as before
 

isladogs

MVP / VIP
Local time
Today, 07:58
Joined
Jan 14, 2017
Messages
18,261
i have tried the docmd.maximize but it does not work. Report opens as before

Just use code similar to that in post #6 but omit DoCmd.Maximize as its redundant here
e.g. on the print button in the calling form, use

Code:
Private Sub cmdPrint_Click()

    DoCmd.OpenReport "YourReportName", acViewPreview

   'then use ONE of the various alternatives including
    DoCmd.RunCommand acCmdZoom100
   ' DoCmd.RunCommand acCmdZoom150
   ' DoCmd.RunCommand acCmdZoom200
   ' DoCmd.RunCommand acCmdZoom500
   ' DoCmd.RunCommand acCmdFitToWindow
   ' DoCmd.RunCommand acCmdPreviewOnePage
   ' DoCmd.RunCommand acCmdPreviewTwoPages
   ' DoCmd.RunCommand acCmdPreviewFourPages
   ' etc
   
End Sub
 

Wysy

Registered User.
Local time
Yesterday, 23:58
Joined
Jul 5, 2015
Messages
333
thanks for all the input it works perfectly if report opened in a normal way. However if opened as a popup (acDialog) it does not work. Can it be that there is no solution for that?
 

isladogs

MVP / VIP
Local time
Today, 07:58
Joined
Jan 14, 2017
Messages
18,261
Using acDialog overrides any other code used including hiding the print preview ribbon

If you really want it to be a popup, set the popup property to Yes.
It will then use the specified display setting e.g. DoCmd.RunCommand acCmdPreviewTwoPages . . .but the preview ribbon will again not appear
 

Wysy

Registered User.
Local time
Yesterday, 23:58
Joined
Jul 5, 2015
Messages
333
I have tried but it does not work. Anyway thank you for all help! I think i can live with this one more click to zoom in. Thanks again.
 

isladogs

MVP / VIP
Local time
Today, 07:58
Joined
Jan 14, 2017
Messages
18,261
I have tried but it does not work. Anyway thank you for all help! I think i can live with this one more click to zoom in. Thanks again.
I have used the code supplied in post #12 for almost 20 years. I know it works ... that is providing you aren't using acDialog.
Frankly I see no possible reason for ever using PrintPreview and acDialog at the same time
 

Wysy

Registered User.
Local time
Yesterday, 23:58
Joined
Jul 5, 2015
Messages
333
I am using an x230 thinkpad on the go and because of the small screen, i thought of a "better" view of the report which only serves a fast data control.
 

Users who are viewing this thread

Top Bottom