Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Progmatically Zoom when report opens 5

Status
Not open for further replies.

nickjar2

Programmer
Jun 20, 2001
778
US
Is there an easy way to specify a report to Zoom to say 50% on opening. There doesn't seem to be a property called 'Zoom' that can be used in VBA.

Cheers,

Nick
 
You can use the following command in VBA to change the zoom on a report:

DoCmd.RunCommand acCmdZoomConstant

Replace the colored word with one of these, they are rather self-explanatory:

acCmdZoom25
acCmdZoom50
acCmdZoom75
acCmdZoom100
acCmdZoom150
acCmdZoom200
acCmdZoomBox

HTH Joe Miller
joe.miller@flotech.net
 
Ironically I just logged on to Tek-Tips to look for this very issue. However, I quickly switched over to my application and tried it and got a runtime error 2046 -- "Command or action 'Zoom75%' isn't available now -- etc etc says I am in an older unconverted db or a read only db none of which is true. (I'd put a screen shot of the message but can't seem to do that here)

Any ideas??
 
Ekim:

Sorry I missed this one, what event did you place the code in? It should be the OnOpen event of the form...

HTH Joe Miller
joe.miller@flotech.net
 
Thanks - I was wondering if anyone would answer


Yes I put it in the On Open event
 
Ok, I found the issue. You can't use it in the Open event of the report. You have to issue it from the form you're calling the report. So go into the command button opening the report and you'll see this:

DoCmd.OpenReport "StDocName"

Add this underneath:

DoCmd.OpenReport "StDocName"
DoCmd.Maximize
DoCmd.RunCommand acCmdZoom10

or whatever zoom level you want. In researching this I also found out there is another zoom constant and that is:

acCmdFitToWindow

HTH Joe Miller
joe.miller@flotech.net
 
Thanks *very* much for the tip. It seems so odd to me that it has to be handled this way much less that it is so convoluted to accomplish something as basic as setting the display size of a report. Oh Well.............

I was actually running the reports from the switchboard manager which I am already committed to in the app so end users could add reports as they needed to. I had to put the code snippet you gave me in a module (one for each report)and call that from the swithcboard. I also had to put a DoCmd.Restore in the close event of each report to put the switchboard form back to its desired size on return. All of this will mean moving away from the end-user but I'm glad to have it in any case.

There is another constant -- acCmdZoomBox that I tried both in the on Open and in the code approach both of which produced the "Not Available" error. Time permitting, I'd like a clue as to what this might do. Also a hint on where I might find a reasonably readable and comprehensible documentation on these intrinsic constants.

I'd like to give you another three stars for your help even though I slipped through the cracks initially. It was worth the wait.

Thanks

 
acCmdZoomBox - no idea what it does, I also looked into it and couldn't find anything of worth. If that changes, I'll let you know.

Listing of constants - search help on the RunCommand function, there is a link to all of the constants access has, documentation of each individual one is slim. There are a couple web sites that are trying to document them, you might try looking for them on google.

Joe Miller
joe.miller@flotech.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top