Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 8th, 2003, 02:30 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 451
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ben Horne
Default Customizing Switchboards in Access

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
__________________
Ben Horne
-------------------------
I don\'t want to sound like I haven\'t made any mistakes. I\'m confident I have.

Most likely using FireFox and concocting my next Macromedia Flash project
Snibworks Forums Moderator

Welcome to the New Age
 
Old September 8th, 2003, 02:49 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 174
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old September 8th, 2003, 05:39 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 451
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ben Horne
Default

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
 
Old September 8th, 2003, 06:35 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 174
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Original Message:
 
Quote:
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
 
Old September 10th, 2003, 06:13 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 451
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ben Horne
Default

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
 
Old September 19th, 2003, 12:46 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 174
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help customizing exsisting store TashaAT VB How-To 8 August 6th, 2008 04:33 AM
Customizing Output bmains SQL Server 2000 1 January 13th, 2004 05:23 PM
Customizing danielwajnberg Crystal Reports 1 December 17th, 2003 08:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.