VBA/Excel/Access/Word/Access/Report Event
Содержание
- 1 Activate toolbar with DoCmd.ShowToolbar
- 2 Close form without saving
- 3 Deactivate toolbar DoCmd.ShowToolbar
- 4 Report Error Event
- 5 Report Open event
- 6 Sub Report_Close()
- 7 Sub Report_NoData(Cancel As Integer)
- 8 Sub Report_Open(Cancel As Integer)
- 9 The Page event gives you the opportunity to do something immediately before the formatted page is sent to the printer: place a border around a page
Activate toolbar with DoCmd.ShowToolbar
<source lang="vb">
Private Sub Report_Activate()
DoCmd.ShowToolbar "AllOrders", acToolbarYes
End Sub
</source>
Close form without saving
<source lang="vb">
Private Sub Report_Close()
DoCmd.Close acForm, "frmReportFilter", acSaveNo
End Sub
</source>
Deactivate toolbar DoCmd.ShowToolbar
<source lang="vb">
Private Sub Report_Deactivate()
DoCmd.ShowToolbar "AllOrders", acToolbarNo
End Sub
</source>
Report Error Event
<source lang="vb">
Private Sub Report_Error(DataErr As Integer, Response As Integer)
If DataErr = 2580 Then MsgBox "Record Source Not Available for this Report" Response = acDataErrContinue End If
End Sub
</source>
Report Open event
<source lang="vb">
Private Sub Report_Open (Cancel As Integer)
Dim blnResultintResult As Integer Dim strWarning As String strWarning = "This report may take some time." & _ " Or press Cancel to abort the operation." intResult = MsgBox (strWarning, vbOKCancel, "Warning") If intResult = vbCancel Then Cancel = True End If
End Sub
</source>
Sub Report_Close()
<source lang="vb"> DoCmd.Close acForm, "frmReportDateRange"
End Sub
</source>
Sub Report_NoData(Cancel As Integer)
<source lang="vb"> MsgBox "There is no data for this report. Canceling report..." Cancel = True
End Sub
</source>
Sub Report_Open(Cancel As Integer)
<source lang="vb"> On Error Resume Next DoCmd.OpenForm "frmReportDateRange", _ WindowMode:=acDialog, _ OpenArgs:="rptProjectBillingsbyWorkCode" If Not IsLoaded("frmReportDateRange") Then MsgBox "Criteria Form Not Successfully Loaded, " & _ "Canceling Report" Cancel = True End If
End Sub
</source>
The Page event gives you the opportunity to do something immediately before the formatted page is sent to the printer: place a border around a page
<source lang="vb">
Sub Report_Page()
Me.Line (0, 0)-(Me.ScaleWidth - 30, Me.ScaleHeight - 30), _ RGB(255, 0, 0), B
End Sub
</source>