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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I setup a macro to print preview reports at 66%

Status
Not open for further replies.

davesaint86

IS-IT--Management
Aug 23, 2007
10
0
0
US
I setup a macro to open (print preview) a report and setup the RunCommand to Zoom the report to 75%. 75% is still too big. 50% is too small. 66% seems to be perfect. There is not a customized Zoom selection feature under RunCommand. Does anyone know of a solution to resolve what I'm trying to do which is(when I select a command button I want my report to open up in the print preview mode at 66%)?
 
This is somewhat undocumented, but works:
Code:
Private Sub Preview_Click()
  Dim stDocName As String

  On Error GoTo Err_Preview_Click

  stDocName = "rptMyReport"     'Specify report name
  DoCmd.OpenReport stDocName, acPreview
  Reports(stDocName).ZoomControl = 66  'Open preview at 66%

Exit_Preview_Click:
  Exit Sub

Err_Preview_Click:
  MsgBox "Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
  Resume Exit_Preview_Click    
End Sub
 
Sorry. You wanted a macro solution. In a Module, add a new function as follows.
Code:
Function CustomZoom(iZoomPercent As Integer) As Boolean
  Dim stDocName As String

  On Error GoTo CustomZoom_Err
  CustomZoom = True
  stDocName = "rptMyReport"     'Specify report name
  DoCmd.OpenReport stDocName, acPreview
  Reports(stDocName).ZoomControl = 66  'Open preview at 66%

CustomZoom_Exit:
  On Error Resume Next
  Exit Function

CustomZoom_Err:
  CustomZoom = False
  MsgBox "Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
  Resume CustomZoom_Exit
End Function
Then, in your macro, add a new line with an action RunCode and function name: CustomZoom(66)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top