Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 22nd, 2003, 09:47 AM
Registered User
Join Date: Dec 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Code alternative for "View / Zoom / Fit for Report

When a report preview is generated it can often be larger than the screen or not centred. Clicking on it makes it fit the screen. I can also produce a Macro which replicates the "View / Zoom / Fit" keystrokes (sendkeys %VZF). I have not found any VBA commands (e.g. which I can put in the report open event which would provide the same action as the keystroke Macro. Is there a VBA code which would produce the same effect please? Thanks.
Old December 27th, 2003, 09:55 PM
Authorized User
Join Date: Nov 2003
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts

You have a couple of choices to accomplish this. The first, and probably easiest is to use the Macro to VBA converter. The following was taken directly from the Microsoft Visual Basic Editor Help.
Convert macros on a form or report to Visual Basic
Open the form or report in form or report Design view.

Point to Macro on the Tools menu, and then click Convert Form's Macros To Visual Basic or Convert Report's Macros To Visual Basic.

To create the code yourself, use the DoCmd object's RunCommand method with one of the following constants:
  • acCmdFitToWindow
  • acCmdZoom10
  • acCmdZoom100
  • acCmdZoom150
  • acCmdZoom200
  • acCmdZoom25
  • acCmdZoom50
  • acCmdZoom75
  • acCmdZoomBox
  • acCmdZoomSelection

Your code would be similar to the following:
Private Sub Report_Open(Cancel As Integer)

    DoCmd.RunCommand acCmdFitToWindow

End Sub
Hope this helps.
Old December 28th, 2003, 07:39 AM
Registered User
Join Date: Dec 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks Embreyo - I have seen the "Macro to VBA converter" in the WROX Access VBA 2000 book but I just hadn't thought of using it in this case - needs a bit of lateral thinking. I'll use this. Mel P

Similar Threads
Thread Thread Starter Forum Replies Last Post
Code Alternative - Managing Roles ryandoah BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 August 1st, 2007 06:14 PM
Report with view ceema Crystal Reports 1 April 4th, 2006 02:45 AM
alternative rows in diff. colours for list view madhukp VB How-To 2 October 7th, 2004 07:12 AM
Login fail Err when view report on Report Server dillig BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 July 22nd, 2004 05:31 AM
Alternative Ways to Close A Form Using Code wscheiman Access VBA 0 November 18th, 2003 12:14 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.