Results 1 to 14 of 14

Clock timer to limit users

  1. #1
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    722

    Clock timer to limit users


    All using 2016...I need code to add a clock or countdown time when the user has been in the database for a specific amount od time..aearxhed the forum without success...for examples..user logs on...after about 30mins...the clock or timer pops up countdown and a msg stating they need to complete their task and log out the datanase...the mgr wants this because they don't want the users to keep the database open if they're not using it...also he wants to limit the amount of users in the database because he feels it would cause problems with too many at one time..50 +users..van anyone help me with ths plsthanks

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    20,578
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    722
    Thanks. Will try this.

  4. #4
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    722
    So; I found this code and it works but a few things I need to modify that I’m having trouble with.

    Code:
    Option Compare Database
    Option Explicit
    ‘Declare a Form Global variable to hold the
    ‘seconds expired since Form was opened.
    Dim TimeCount As Long
    Private Sub Form_Open(Cancel As Integer)
    ‘Set the Form’s Timer to 1 second intervals (1000 tics = 1 Second)
    Me.TimerInterval = 1000
    End Sub
    
    Private Sub Form_Timer()
    'Increment the TimerCount variable by 1
     TimeCount = TimeCount + 1
     'Display the current seconds remaining in the 'text box corner of form
     Me.txtCounter.Value = 60 - TimeCount
     'If the Seconds Counter (TimerCount) is now equal
     'to 40 seconds then the text color changed to Red
     If TimeCount = 40 Then
     Me.txtCounter.ForeColor = vbRed
     End If
     If TimeCount = 61 Then
     'Close the Access Program when the counter is equal to 61 seconds
     DoCmd.Quit acQuitSaveAll
    End If
    End Sub
    1st-This sets the countdown to 60 secs; I need to change to 60 minutes. Also; this shows the countdown as a whole number; ex.
    60, 55, 58 ….I need it in mm:ss like 59:10, 59:09….
    2nd-Form_Timer code shows that at 20secs left will turn to red. I not only need the counter to turn red at 40 but before I would like from 59mins to 16 green; 15mins to 6mins yellow and the final 5mins red. Can someone help please…

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    20,578
    See if post 5 here works for you.

    https://access-programmers.co.uk/for...d.php?t=166993

    Setting the color is a simple matter of testing the counter and setting the back color property of the textbox.

    If Counter < 123 Then
    ...
    ElseIf Counter < 456 Then
    ...
    Else
    ...
    End If
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    722
    This is exactly what I needed..still playing around with the colors...got it to work with the other code but not with this one..but will keep trying. Thanks!!

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    20,578
    No problem, post back if you're still stuck on that part.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    722
    So, I added the to the code after Loops=Loops +1:
    Code:
    If SecondsToCount > 60 Then me.lblCountDown.ForeColor =vbGreen ElseIf SecondsToCount < 60 Then me.lblCountDown.ForeColor =vbRed End If
    when I run it, the color is green but never changes to red...what did I do wrong?

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    20,578
    If you used his code, SecondsToCount is a constant; it never changes. You'd want to test the Loops variable.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    722
    Gotcha....I'll work it out...Thanks so much for your help!

  11. #11
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    722
    So, I have this working the way I want it to...I have the timer on the switchboard set to coundown from 60mins once the database opens. When it gets to 15mins, it turns red for the remaining countdown. But, If the user is working on a form within the database, the switchboard is minimized n can't see the timer. So they want when the timer gets to 15mins, if the switchboard is minimized, they want it to maximize so they can keep up with the timer..any suggestions? I put the countdown on the switchboard so I would have to put it on all the forms in the database the user can have open..

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    20,578
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  13. #13
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    722
    Got it! Thanks so much..

  14. #14
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    20,578
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 01-09-2017, 06:20 PM
  2. Replies: 10
    Last Post: 03-22-2016, 09:56 PM
  3. Limit Data that Users see in Database
    By katkth7533 in forum Access
    Replies: 6
    Last Post: 02-11-2015, 08:09 AM
  4. Limit users to their Department
    By Zachrareth in forum Programming
    Replies: 7
    Last Post: 09-09-2013, 08:17 AM
  5. Replies: 6
    Last Post: 03-08-2013, 11:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Tech Forums: Microsoft Office Forums