|
Subject:
|
Customizing Switchboards in Access
|
|
Posted By:
|
Ben Horne
|
Post Date:
|
9/8/2003 2:30:33 PM
|
Hi,
I would like to customize my existing switchboard that I have as part of my Music Inventory(Access)database. What I want to do is create a procedure that tells the user that they've been inactive for a while and gives them a limited amount of time before they are logged off. How can I do this Is it possible to do this in VBA
Any help would be greatly appreciated
Thanks,
majora
|
|
Reply By:
|
BethMoffitt
|
Reply Date:
|
9/8/2003 2:49:06 PM
|
Create a form called frmIdleTime. You also need a table to store the following two fields. I have a system settings table which stores the info:
INACTIVITY_TIMER_INTERVAL (text) IDLE_TIME (Yes/No)
In your startup routine, use:
DoCmd.OpenForm "frmIdleTime", , , , , acHidden
The following code goes into frmIdleTime:
Option Compare Database
Private Sub Form_Timer() 'IDLEMINUTES determines how much idle time to wait 'before running IdleTimeDetected subroutine IDLEMINUTES = INACTIVITY_TIMER_INTERVAL If IDLE_TIME = -1 Then 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 active form & 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 & 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 Else Exit Sub 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, 48 Application.Quit acSaveYes End Sub
Regards,
Beth M
|
|
Reply By:
|
Ben Horne
|
Reply Date:
|
9/8/2003 5:39:18 PM
|
OK, so should I look to see if there is a system settings table in Access? When I read the part about storing the 2 fields you mentioned about, I started thinking that there might be a system table in Access that has the INACTIVITY_TIMER_INTERVAL and IDLE_TIME fields. Am I right in thinking this
Ben
|
|
Reply By:
|
BethMoffitt
|
Reply Date:
|
9/8/2003 6:35:57 PM
|
Original Message: quote: OK, so should I look to see if there is a system settings table in Access? When I read the part about storing the 2 fields you mentioned about, I started thinking that there might be a system table in Access that has the INACTIVITY_TIMER_INTERVAL and IDLE_TIME fields. Am I right in thinking this?
There is a system table in Access, but not one that you can/or even should modify. I have my own called tblSysInfo which contains these two fields, and others that allow me to set system wide settings on the application which are custom for my app, not access in general.
Regards,
Beth M
|
|
Reply By:
|
Ben Horne
|
Reply Date:
|
9/10/2003 6:13:08 PM
|
Hi Beth,
I read your reply to me about the last question I had regarding letting the database user know that they have been inactive for a while and setting a specific amount of time to wait before the user is logged off. I'm just wondering, how can I let the user know how much time he/she has before the database closes automatically? I need there to be some way for the user to see how much time they have left to respond before they are logged off automatically as I am thinking about distributing my Music Inventory 2001 database.
Any help on this issue would be appreciated
Thanks,
Ben
|
|
Reply By:
|
BethMoffitt
|
Reply Date:
|
9/19/2003 12:46:58 PM
|
Sorry for the delay Ben. I just saw your follow-up post. Actually, I don't know. I haven't taken it this far. But, just off the top of my head, use a form with an invisible unbound text box of date/time field of Now(); add another one of Now()+[ValueInTable]and display the results in a third by doing the calculation using a refresh command ... Hmmmm... now that I'm thinking it through.. just create a function to do the following calculation: (Now()+([INACTIVITY_TIMER_INTERVAL]*60))-Now() And refresh the form to display current value.
HTH,
Beth M
|