Results 1 to 15 of 15
  1. #1
    Join Date
    Feb 2004
    Location
    Irving, TX (Dallas, Fort Worth)
    Posts
    379

    Unanswered: Quick Help Please

    All,

    I have DB designed with FE & BE and need a script to force users off the BE for maintainance with "Compact & Repair" as default maint.

    I know there is a script out there, but forgot the URL.

    URLs please!!

    Thanks!

    DBS4M

  2. #2
    Join Date
    May 2005
    Posts
    1,191
    I don't know how to "force users off", but you can at least find out who's in it with this bit of code. Then you can walk over with your cudgel of choice and do some "persuading".
    Me.Geek = True

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I don't think you can force people off
    there is however code which can stop people opening a db
    you can use other techniques to find who is connected and cajole them to get out of the db
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Jun 2007
    Location
    Maitland NSW,Australia
    Posts
    388
    Have a look at this site, there is an item Log users off and others that may be helpful.
    Roger's Access Library: ALPHABETICAL INDEX TO SAMPLES

  5. #5
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    I dunno... a well timed DoCmd.Quit does a pretty good job of forcing users out.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  6. #6
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    I personally would never write code to force users out of an mdb.

    Instead, I use the little script here:
    http://www.dbforums.com/6274786-post19.html

    (see items #4 and #7 in the above link.)

    I never need to force a user out of the mdb/mde, I can tell who's currently using the mdb/mde, I can tell when a user LAST opened the mdb/mde and I can even copy new code (or compact/repair) at ANY time by just using this little vbs script.
    Last edited by pkstormy; 09-24-09 at 23:43.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  7. #7
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    And how would you deal with an upgrade that REQUIRES everyone out and one user has locked their system and left the database open in it and then gone for a two day break???

    The cloning launching is a great start, but I compliment that with a "force quit" admin command that once issued, does a DoCmd.Quit after 5 minutes. Then, even if the user has locked up a record, then left, you can get them out without having to take drastic measures.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  8. #8
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I prefer the tried and tested method, if the phone call doesn't get them to log out I like to wander round and grasp the errant users warmly by the throat or introduce 'em to my bessie mate from technical support who wields the cricket bat

    leaving your computer on when you are not at your desks is an instant disciplinary in virtually every site I've worked on in the last 10 years, and on the rare occasions it isn't it usually is after hurricane me sweeps through the premises
    I'd rather be riding on the Tiger 800 or the Norton

  9. #9
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Yeah yeah, but a forced quit command solves my problem without having to get anyone fired
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  10. #10
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    I agree with StartTrekker. Sometimes you're obliged to take radical measures:
    Code:
    Declare Function InitiateSystemShutdown Lib "advapi32.dll" Alias "InitiateSystemShutdownA" _
        (ByVal strMachineName As String, ByVal strMessage As String, ByVal dwTimeOut As Long, _
        ByVal lngForceAppsClosed As Long, ByVal bRebootAfterShutdown As Long) As Long
    
    Public Function Shutdown(Optional strMachineName As String, Optional strMessage As String, _
        Optional lngTimeOut As Long, Optional lngRebootAfterShutdown As Long)
    
        Dim lngApiResult As Long
        Dim lngForceAppsClosed As Long
        
        If IsMissing(strMachineName) Then
            strMachineName = ""
        End If
        If IsMissing(strMessage) Then
            strMessage = ""
        End If
        If IsMissing(lngTimeOut) Then
            lngTimeOut = 0
        End If
        If IsMissing(lngRebootAfterShutdown) Then
            lngRebootAfterShutdown = False
        End If
        lngForceAppsClosed = True
        lngApiResult = InitiateSystemShutdown(strMachineName, strMessage, lngTimeOut, lngForceAppsClosed, lngRebootAfterShutdown)
    
    End Function
    It works great provided you have admin rights on the network.
    Have a nice day!

  11. #11
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Quote Originally Posted by StarTrekker
    And how would you deal with an upgrade that REQUIRES everyone out and one user has locked their system and left the database open in it and then gone for a two day break???

    The cloning launching is a great start, but I compliment that with a "force quit" admin command that once issued, does a DoCmd.Quit after 5 minutes. Then, even if the user has locked up a record, then left, you can get them out without having to take drastic measures.
    Using the script, users can easily be forced out of their application at any time without harm (I had to kick a few out of their cloned copy), but since the script overwrites the corrupted file when it's ran again, the user gets a fresh copy of the source mdb when they open it again. The "source" mdb is never opened and stays safe.
    Last edited by pkstormy; 10-01-09 at 00:18.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  12. #12
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Some places I worked, I sent an Immediate Message to the users to close out of the database. Not many networks utilize this feature though.

    I also use a "Reminder" type feature in my MSAccess apps where I can send an instant message to all users using my app.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  13. #13
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    @ Sinddho, Does that shut the whole computer down?? Geez, now that IS radical!!! I only ever go so far as to quit the application!

    @ PK, you don't understand the situation I am referring to. The computer is in an office somewhere, maybe with a locked door, the FE is OPEN and has a record lock in place, locking up the BE. You don't even know where the office is. You need to make changes to the BE. Today. Nothing but forcing the user out of the system (DoCmd.Quit) or terminating connections at the server will clear that. I have only encountered this situation half a dozen times... the first time, we rebooted the SERVER to clear the lock!! lol

    At that point I decided to make sure all my applications have a utility (that only the admin user can get to) that when triggered, would issue a DoCmd.Quit after 5 minutes -- regardless of what the user was doing. It works quite well and nobody need get fired for locking and leaving!
    Last edited by StarTrekker; 10-01-09 at 00:38.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  14. #14
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    You're right ST, I missed it. Thought it was mainly about FE not BE.

    In my frontend though, I have a linked table where which has a Yes/No field called DoShutdown which is in a table called tblShutdown (again linked). Then in the Timer event of my mainformbackground (which is always open), the code will check this value every 10 minutes or so. If it's true, it pops up a form message saying it's quitting and closes the app.

    I can set this value in the backend and then just wait for the frontends to close.
    Last edited by pkstormy; 10-02-09 at 02:30.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  15. #15
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    That's basically what mine does too. Except mine does it every 5 minutes. I hate waiting!!

    I also polished mine by putting it in my dlgToolsOptions form as an administrative ability.... along with a custom message for users logged in to see. So admins can log in, go to tools options, set a message like "Get out ya mongrels, I need to do some updates (should be up again in 20 minutes)." and then hit "Enable AutoQuit".

    In 5 minutes, everyone is out and cannot log back in until the AutoQuit is disabled again.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •