How do I get the report to not spend time pulling up the data when I'm
going to bail out of the report anyway?
Below is the code in my report. I first show the user a form where
they can select some filtering parameters which I put in Getz's
TaggedValues class. But they can hit a Cancel button if they decide
they don't want any report. When I test the Cancel button I'd like the
report to close immediately but it seems to spend some time pulling up
data first.
(I've tried to put docmd.Close in the Report_Open but that closes the
whole database so I've been putting it in the Report_Activate.)
The Record Source is a query and the report has no fields that are
calculated, all fields are straight from the query.
Any advice?
THANKS!
----- Here is the code...
Option Compare Database
Option Explicit
Public CloseNow As String ' I know boolean would be better
Private Sub Report_Open(Cancel As Integer)
Dim strMyFilter As String
Dim tv As TaggedValues
CloseNow = "No" ' Public string
' This form sets TaggedValues in both OK and Close
' buttons, then sets its Visibile = false
DoCmd.OpenForm "frmSelectOpCheckVars", , , , , acDialog
Set tv = New TaggedValues
tv.Text = Forms!frmSelectOpCheckVars!txtMyTags.Tag
' Close the selection form
DoCmd.Close acForm, "frmSelectOpCheckVars"
If tv.Item("Canceled") = "Yes" Then
MsgBox "Click OK to close. This may take a few seconds... ", ,
"REPORT CLOSING"
CloseNow = "Yes"
Else
' set strMyFilter here...
Me.Filter = strMyFilter
Me.FilterOn = True
End If ' end of If canceled = yes
Set tv = Nothing
End Sub
Private Sub Report_Activate()
If CloseNow = "Yes" Then
DoCmd.Close
End If
End Sub