Closing code

  • Thread starter Thread starter Eric G
  • Start date Start date
E

Eric G

I have an 'invisible' form that times out after 5 minutes of activity
and 'Quits' the application.

Would someone be able to tell me how I can have this same 'timer' form
close a report that _may be open, but run only part of its On_Close
code? That is, skip the first few lines of the On_Close but run the
last part and then Quit the app.?

Failing that, is there some way for this timer form to check if the
report is open, and if it is, run code that's required (perhaps store
this code somewhere else?)

Tips on solving this problem would be appreciated. Eric
 
Hi Eric

You could set a global boolean variable in your Form_Close (or Form_Unload)
event, and test the boolean in Report_Close to determine which parts of the
code to run.

Alternativly, you could also determine if the report is open and run the
code externally if you prefer. SysCmd() will tell the object state (open or
not), or in later versions you can set the IsLoaded property of the member
of AllReports.
 
Hi Eric

You could set a global boolean variable in your Form_Close (or Form_Unload)
event, and test the boolean in Report_Close to determine which parts of the
code to run.

Alternativly, you could also determine if the report is open and run the
code externally if you prefer. SysCmd() will tell the object state (open or
not), or in later versions you can set the IsLoaded property of the member
of AllReports.


Thanks Allan, I'll see if I can get something going. Eric
 
Hi Allen,
Alternativly, you could also determine if the report is open and run the
code externally if you prefer. SysCmd() will tell the object state (open or
not), or in later versions you can set the IsLoaded property of the member
of AllReports.


I'm really close to getting this SysCmd thing working, but I could
still use some help.
The syntax is a little convoluted.
I've been trying the following which hasn't been working:

If SysCmd(acSysCmdGetObjectState, acReport, RptDetentionList) = 1 Then
Call Process2
End If


There is only one example in the Help file for GetObjectState, as
follows:

Dim intObjType As Integer, strObjName As String, intObjState As
Integer

intObjType = Application.CurrentObjectType
strObjName = Application.CurrentObjectName
intObjState = SysCmd(acSysCmdGetObjectState, intObjType, strObjName)
If intObjState <> 0 Then
 
Hi Allen,

Alternativly, you could also determine if the report is open and run the
code externally if you prefer. SysCmd() will tell the object state (open or
not), or in later versions you can set the IsLoaded property of the member
of AllReports.

OK, I got her working now.
I guess the report just needed to be in " " quotes. Funny thing is
that the Help file example didn't have the quotes.

Sub IdleTimeDetected(ExpiredMinutes)

If SysCmd(acSysCmdGetObjectState, acReport, "RptDetentionList") Then
Call Process2
End If

Application.Quit acSaveYes

End Sub
 
Back
Top