Results 1 to 9 of 9
  1. #1
    Bruce is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    72

    Force users to log off

    MS-Access 2003 running security with individual logins. How do I force all users to log off?



    Thanks!

  2. #2
    c_smithwick is offline Underpaid Programmer
    Windows 7 Access 2003
    Join Date
    Jan 2010
    Location
    Lakeside, CA
    Posts
    49
    I open a hidden form in my main database (that stays open as long as the database is open) when the user first logs in, with a timer event that fires every 30 sec or so. When the event fires, a value is checked in a lookup table (Yes/No data field) that I can toggle with an update query against the table. If the value is found to be TRUE, then a warning message is displayed to the user (on a timed form which automatically closes after 30 seconds - prevents me from having to wait until the user clicks "OK" on a standard message box) and the app is then closed. If the user tries to reopen and the value is still set to true, then the user is warned and the database is immediately closed.

    I use this when I need to make updates - I toggle the value, wait 30-45 sec until all users are thrown out, make my updates, and then toggle the value back, allowing users to log in once more. Works great for me, I have been using this method for two years now on a database I maintain without problems.

    I actually have an "update" function that I run in a duplicate development database on my local hard drive. It pops up a form listing all the forms, modules, queries, etc and let's me select which ones I have updated, then sets the toggle value in the lookup table, waits until the ldb locking file is gone by looping a dir function on the server directory where the main database resides. When the Dir function returns a null string (indicating that all users are out), then the function copies all the changed forms, modules, etc from my development database to the main database and resets the toggle value allowing users to log back in. All I have to do is run the update macro which opens a form, click the stuff I need to update, click "GO" and sit back and wait until updates are made. Once I got it written it sure saved me a lot of time when making updates. I have attached a sample you can cannibalize if you want . Once you run the macro it loads the form listing all of your components. Check to ones you want to update and click GO. I think all the code is pretty simple to follow.

  3. #3
    Bruce is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    72
    Thanks for the info. I'm still a novice with Access and could not reverse engineer your code so I understood it. Is there a more simple way to skin this cat?

    Much Thanks!

  4. #4
    c_smithwick is offline Underpaid Programmer
    Windows 7 Access 2003
    Join Date
    Jan 2010
    Location
    Lakeside, CA
    Posts
    49
    Yes - get up from your chair and go around to each of your users and say, "please log off". Short of that, your going to have to learn a bit of VBA. The code I sent you is VERY basic and about as simple as I've seen, so sorry, I can't point you to a simpler solution.

  5. #5
    pkstormy's Avatar
    pkstormy is offline Access/SQL Server Expert
    Windows XP Access 2003
    Join Date
    Mar 2010
    Location
    Madison
    Posts
    682
    I wouldn't recommend any type of coding which automatically logs off or closes an mdb. This can lead to data corruption should a user be in the midst of editing a record.

    See here for an ideal solution which works very nicely:
    http://www.dbforums.com/6274786-post19.html

  6. #6
    Noor-E-Masum is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2012
    Posts
    3
    Quote Originally Posted by c_smithwick View Post
    I open a hidden form in my main database (that stays open as long as the database is open) when the user first logs in, with a timer event that fires every 30 sec or so. When the event fires, a value is checked in a lookup table (Yes/No data field) that I can toggle with an update query against the table. If the value is found to be TRUE, then a warning message is displayed to the user (on a timed form which automatically closes after 30 seconds - prevents me from having to wait until the user clicks "OK" on a standard message box) and the app is then closed. If the user tries to reopen and the value is still set to true, then the user is warned and the database is immediately closed.

    I use this when I need to make updates - I toggle the value, wait 30-45 sec until all users are thrown out, make my updates, and then toggle the value back, allowing users to log in once more. Works great for me, I have been using this method for two years now on a database I maintain without problems.

    I actually have an "update" function that I run in a duplicate development database on my local hard drive. It pops up a form listing all the forms, modules, queries, etc and let's me select which ones I have updated, then sets the toggle value in the lookup table, waits until the ldb locking file is gone by looping a dir function on the server directory where the main database resides. When the Dir function returns a null string (indicating that all users are out), then the function copies all the changed forms, modules, etc from my development database to the main database and resets the toggle value allowing users to log back in. All I have to do is run the update macro which opens a form, click the stuff I need to update, click "GO" and sit back and wait until updates are made. Once I got it written it sure saved me a lot of time when making updates. I have attached a sample you can cannibalize if you want . Once you run the macro it loads the form listing all of your components. Check to ones you want to update and click GO. I think all the code is pretty simple to follow.
    Many many thanks to you brother, I will try it.-Masum. Oh sorry brother, it does not work.

  7. #7
    Noor-E-Masum is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2012
    Posts
    3
    I am new user of that sites as well ms access. I collect a sample about my problem. I will try it. Thank you.

  8. #8
    Noor-E-Masum is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2012
    Posts
    3
    I thought it will be very helpfull, but it does not work. bye

  9. #9
    youwillc is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    1
    Hi! I am totally new (not that new) and not sure exactly what to do with this file. Should I export everything to my DB? If I open yours how long do I wait before it logs me off? + Any reply - a helpful one would be really appreciated! Thanks again!

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

Similar Threads

  1. multiple users
    By ramkitty in forum Access
    Replies: 1
    Last Post: 03-22-2010, 07:15 PM
  2. How to have multiple users
    By Eric1066 in forum Access
    Replies: 5
    Last Post: 11-19-2009, 05:14 AM
  3. A way to force Access to update external file?
    By gkun in forum Import/Export Data
    Replies: 0
    Last Post: 10-27-2009, 06:11 PM
  4. How to force carriage return between strings?
    By Divardo in forum Reports
    Replies: 1
    Last Post: 05-21-2009, 10:50 AM
  5. Force writing from the right in a field?
    By Looping in forum Forms
    Replies: 0
    Last Post: 01-23-2006, 03:03 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
  •  
Other Forums: Microsoft Office Forums