|
在窗体模块中添加如下过程:
- Private Function AutoToPage(ReportName As String)
- Select Case Reports(ReportName).Pages
- Case 1
- DoCmd.RunCommand acCmdPreviewOnePage
- Case 2
- DoCmd.RunCommand acCmdPreviewTwoPages
- Case 3, 4
- DoCmd.RunCommand acCmdPreviewFourPages
- Case 5, 6, 7, 8
- DoCmd.RunCommand acCmdPreviewEightPages
- Case Else
- DoCmd.RunCommand acCmdPreviewTwelvePages
- End Select
- End Function
复制代码
然后在打开报表的代码后调用,如:- Private Sub 预览_Click()
- On Error GoTo Err_预览_Click
- Dim stDocName As String
- stDocName = ChrW(20570) & ChrW(-29401) & ChrW(21333)
- DoCmd.OpenReport stDocName, acPreview, , "[单号]='" & Me.单号 & "'"
- AutoToPage stDocName
- Exit_预览_Click:
- Exit Sub
- Err_预览_Click:
- MsgBox Err.Description
- Resume Exit_预览_Click
- End Sub
复制代码 |
|