I don't know if you're still following this, but I have now discovered that
the detect idle time form from the Microsft sample database called
FRMSMP97.EXE running in the background, is fiddling with the actuve control
and whenever my code does a DoCmd.GoToControl "ControlName", I now get an
error message saying there is no field called 'ControlName' in the current
record.
The form does as is advertised and detects no activity in the database and
logs people off after a predetermined time, but also interferes with any
code doing with control names on any form in the database.
The code in the DetectIdleTime module is as follows:
Private Sub Form_Timer()
' IDLEMINUTES determines how much idle time to wait for before
' running the IdleTimeDetected subroutine.
Const IDLEMINUTES = 5
' DLookup("[LetterLabel]", "tblButtons", "ControlID=98")
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)
' Dim Msg As String
' Msg = "No user activity detected in the last "
' Msg = Msg & ExpiredMinutes & " minute(s)!"
' MsgBox Msg, 32
Application.Quit acSaveYes
End Sub
Has anyone got any ideas how I can stop this from interfering with my
DoCmd.GoToControl commands?
dixie
"dixie" <di****@dogmail.com> wrote in message
news:gH***************@nnrp1.ozemail.com.au...
Strangely enough, the code I "borrowed" from the file FRMSMP97.EXE is now
working. I am now loading it as a hidden form when my applciation opens
and it is working "as advertised". Thanks for pointing out the source to me
Allen.
dixie
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:3f**********************@freenews.iinet.net.a u... If you have error handling in your routines, you may need to disable it
until you get this working?
Without checking the code you are referring to, you may need to undo the
form if it is dirty so that it can be closed?
Could there be other forms open as well, or other pending things you
need to deal with?
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"dixie" <di****@dogmail.com> wrote in message
news:lx****************@nnrp1.ozemail.com.au... Thanks, I checked that one out Allen. I got the file which
illustrates it from Microsoft and found that it works on their form that has the code
behind it, but when I put that code in a hidden from as suggested in
the article, it doesn't give me a message at all. I set it to 1 minute
and gave up after 20 minutes. What I did notice however is that when I run
their sample database, the cursor flashes on and off regularly in its
control. However, when I run my database, the cursor makes a few sluggish
attempts to flash and then just sort of disappears from view. I wondered if that
might be causing the problem and if so, what causes that to happen.
dixie
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:3f**********************@freenews.iinet.net.a u...
> See:
> http://www.mvps.org/access/general/gen0034.htm
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia.
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "dixie" <di****@dogmail.com> wrote in message
> news:jS***************@nnrp1.ozemail.com.au...
> > Is it possible to have Access do a docmd.quit if a key is not
pressed for
> 5
> > minutes? I have been trying to get users out of a program when it is > > necessary to update it. To do this, I have been opening a warning
form > with
> > a timer that will log them off with a docmd.quit ater one minute. It > seemed
> > to work for me on a single computer, but on a network, it has not been > > successful at all. I am unsure why, but it is possible that the
computers
> > have gone into a locked state after a certain time requiring the user to > log
> > back on with a password - they are using Windows XP Professional.
I > thought
> > that if I could have the program monitor for keypresses from a
hidden > form,
> > then I could close the application after a certain time without a key > press.
> >
> > If this is possible, how do I get access to run a docmd action
after a > > certain time with no key presses? Anyone?
>
>