Timer Function Problems

jmriddic

Registered User.
Local time
Today, 11:02
Joined
Sep 18, 2001
Messages
150
I read the dialogue between ghudson and bikeman77. I decided to follow the route that microsoft suggested which was to use a macro to execute the form. Problem is I don't think it launch the form because it went past five minutes and didn't shut the datbase down. The way my database works is that it launches a form at startup where I choose a job position or create a new one and it takes me to my enter/edit form. I used the same VBA code but theirs differed in how they executed it. Any suggestions?
 
The problem

Hi,

Well I launch the database. Click on the form to select a position and I go into my entry form. I just sit there for minutes on end and it never closes. Code is verbatim the microsoft site suggested by ghudson. I am running 2003 Access.
 
jmriddic said:
Code is verbatim the microsoft site suggested by ghudson.

There's still not much we can suggest as you haven't given either the code or a link to the thread you are referring to.
 
Works fine in A97.

Do you get the message box?
Did you include: -
Application.Quit acSaveYes
In Sub IdleTimeDetected(ExpiredMinutes)?
Did you set the timer interval to 1000? <----------------------

If you can’t get it to work can you post the code you are using?

Regards,
Chris.
 
Update

I am using the code verbatim but I am using the one without the message box so it would close right away. I did not populate the interval at first so that's why it didn't execute. Now the application hangs. I have tried everything from Applicataion.Quit to DoCmd.Quit with and without arguements to doing the following:

DoCmd.Close
DoCmd.RunCommand acCmdExit

Not sure at all what the problem is.
 
If you can’t get it to work can you post the code you are using?
 
Code

Option Compare Database

Private Sub Form_Timer()
' IDLEMINUTES determines how much idle time to wait for before
' running the IdleTimeDetected subroutine.
Const IDLEMINUTES = 5

Static PrevControlName As String
Static PrevFormName As String
Static ExpiredTime

Dim ActiveFormName As String
Dim ActiveControlName As String
Dim ExpiredMinutes

On Error Resume Next

' Get the active form and control name.

ActiveFormName = Screen.ActiveForm.Name
If Err Then
ActiveFormName = "No Active Form"
Err = 0
End If

ActiveControlName = Screen.ActiveControl.Name
If Err Then
ActiveControlName = "No Active Control"
Err = 0
End If

' Record the current active names and reset ExpiredTime if:
' 1. They have not been recorded yet (code is running
' for the first time).
' 2. The previous names are different than the current ones
' (the user has done something different during the timer
' interval).
If (PrevControlName = "") Or (PrevFormName = "") _
Or (ActiveFormName <> PrevFormName) _
Or (ActiveControlName <> PrevControlName) Then
PrevControlName = ActiveControlName
PrevFormName = ActiveFormName
ExpiredTime = 0
Else
' ...otherwise the user was idle during the time interval, so
' increment the total expired time.
ExpiredTime = ExpiredTime + Me.TimerInterval
End If

' Does the total expired time exceed the IDLEMINUTES?
ExpiredMinutes = (ExpiredTime / 1000) / 60
If ExpiredMinutes >= IDLEMINUTES Then
' ...if so, then reset the expired time to zero...
ExpiredTime = 0
' ...and call the IdleTimeDetected subroutine.
IdleTimeDetected ExpiredMinutes
End If
End Sub

Sub IdleTimeDetected(ExpiredMinutes)
DoCmd.Close
DoCmd.RunCommand acCmdExit
End Sub
 
Well, it works for me in Access97.

Next step might be to upload a sample of the problem.
I would need it in A97 but others can help with A2K3 if need be.
Strip out anything not needed, compact and zip.
It will need to be less than 400K.

Sorry…no good news so far.

Regards,
Chris.
 
Found the Problem

Its the Application.Quit that hangs it up or similar commands that do the same thing. I tried the MsgBox Option and it worked perfectly even when the form was not the active window on my screen but it was messing up the other way even if the form was the active window. Now I am using the 2003 libraries but the file format is 2000 so 2000 and up users can use the db. I don't think would make a difference.
 
Can I fix this

Chris or anybody is it possible to fix this problem?
 
I thought you had found the problem.
Can you post a little demo?
 
How do I post a demo for the problem?

Hi Chris,

I know where the problem lies but I don't know if I can correct it. So how do I post a demo?
 
Make a copy, strip out anything not needed, compact and zip.
It will need to be less than 400K.
Then attach it to a reply.

11:25PM here…zzzzzzzzz
 
Copy of database

You must be in Australia or New Zeland one.
Thanks for taking a look. its pretty blank so fill free to mess around in it. The word report buttons won't work of course.
 

Attachments

This appears to work OK: -

Code:
Sub IdleTimeDetected(ExpiredMinutes)

    Me.TimerInterval = 0

    oMsgBox.PopUp "No user activity detected in last " & CStr(ExpiredMinutes) & " minutes." & vbCrLf & vbLf & _
                  "Database is therefore being closed", 10, "Closing database", vbInformation
     
    DoCmd.Close acForm, Screen.ActiveForm.Name
    Application.Quit acQuitSaveNone

End Sub
The database seems to require decompiling fairly often…don’t know why.

I had to change back to Microsoft Word 8.0 Object Library because I don’t have version 11 on my machine.

A2K demo attached.

Regards,
Chris.
 

Attachments

It works

Hi Chris,

Don't know why it want to decompile but the good news it seems to work.
Thanks for the help.
 

Users who are viewing this thread

Back
Top Bottom