Home  |   French  |   About  |   Search  | mvps.org  

What's New
Table Of Contents
Credits
Netiquette
10 Commandments 
Bugs
Tables
Queries
Forms
Reports
Modules
APIs
Strings
Date/Time
General
Downloads
Resources
Search
Feedback
mvps.org

In Memoriam

Terms of Use


VB Petition

Reports: Custom Zoom in Reports

Author(s)
Radu Lascae

The build in method for zooming a report in Preview mode (RunCommand  acCmdZoom*) does not allow for custom zoom  levels.

Instead of using DoCmd.RunCommand acCmdZoom150, or another built-in constant, you may use the ZoomControl property of the Report object. Use with care! The property is not documented anywhere.

'*********** Code Start ************
' This code was originally written by Radu Lascae
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Radu Lascae
'
Function PreviewAndZoomReport(ReportName As String, ZoomCoeff As Integer)
    'function written by Radu Lascae <R.Lascae@ind.tno.nl>,
    'use it at will standard disclaimer applies
    '
    'Instead of using DoCmd.RunCommand acCmdZoom150, or another built-in
    'constant, you may use the ZoomControl property of the Report object.
    'Use with care! The property is not documented anywhere.
    'I have found it in a code snippet from a VB5 book.
    '
    'ZoomControl is a Variant that accepts virtually everything
    'that can be converted to a number, positive, negative, small or large.
    'The property behaves nicely if "normal" numbers are passed.
    'This function allows an integer from 0 = ZoomToFit to 2500(%).
    'If the value is out of range, the function uses ZoomToFit.
    'The highest readable zoom I could achieve is about 2900(%) (!!!), this
    'depends on the minimum scrollbar increment.
    '
    'The property is available for any open report that has the focus,
    'irrespective if the toolbar is visible or not.
 
    On Error GoTo Error_Handler
 
    If Not (ZoomCoeff >= 0 And ZoomCoeff <= 2500) Then
        ZoomCoeff = 0
    End If
 
    With DoCmd
        .OpenReport ReportName, View:=acViewPreview
        .Maximize
    End With
    Reports(ReportName).ZoomControl = ZoomCoeff
 
    Exit Function
Error_Handler:
    MsgBox Err.Description
    Resume Next
End Function
'*********** Code End ************

© 1998-2010, Dev Ashish & Arvin Meyer, All rights reserved. Optimized for Microsoft Internet Explorer