How can I Unload an object?

jguscs

Registered User.
Local time
Today, 10:52
Joined
Jun 23, 2003
Messages
148
I've got the following process:

-Switchboard opens, allowing the user to run a report
-there's some conditional checking in the report_open procedure to see if the report should really be run:
-if the report should be run, it continues past the conditional checking
-if the report should not be run, the Switchboard is opened and the report is closed... HOWEVER:
The report doesn't want to close! because it's in the middle of its process. SO, what I want to do is "unload" the report/object from memory so it can be closed.

how can I do this (from the switchboard)?
I'd imagine some sort of checking to see if the report is loaded in memory and then, if it is, unload it.
the code Unload "My Report" doesn't work. It says Type Mismatch.
 
Last edited:
Do you set the Cancel Parameter in the Reports Open Event = True?
 
What do you mean, like in the header of the report open procedure?:
Private Sub Report_Open(Cancel As Integer)

Or do you mean in the call to open the report from the switchboard?:
DoCmd.OpenReport "My Report", acViewPreview, , ""
 
How are you checking to see if the report needs to be run?
If it is based on whether any records are returned from a query you could use
Code:
If DCount("*", "QryName") > 0 Then
    DoCmd.OpenReport "RptName", acViewPreview
Else
    DoCmd.OpenForm "FormName"
    End If
 
-there's some conditional checking in the report_open procedure to see if the report should really be run:


In the Private Sub Report_Open do you set Cancel = True?

Example
Code:
Private Sub Report_Open(Cancel As Integer)

IF Condition="Does not Meet all Conditions" Then
  Cancel=True
  Exit Sub
End If

End Sub

Cancel is used to cancel the Event (In this case the Open Event of the Report) This would close the Report Object. Using Exit Sub right after setting Cancel to True stops running the rest of the Conditional statements in the Procedure.
 

Users who are viewing this thread

Back
Top Bottom