Results 1 to 5 of 5
  1. #1
    redekopp is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2015
    Location
    Saskatoon
    Posts
    108

    Log user off computer on database exit

    As the title suggest, we have a locked down the database that is accessible via remote desktop (to a server running 2012). It auto launches for them but when they exit the database we want it to log them off.

    Has anyone come across a code for this?

    p.s. I know this would be simple with a remote app but we are not using a domain joined server in this case.



    Thanks!

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Not sure you can do this from Access. Maybe have another process running in background to check for the Access locking file .laccdb and if not detected log off users?

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    There is no action to detect access closing, so you must have a small HIDDEN form.
    this form would open in autoexec macro with the main form.
    this form has the shutdown command. When access closes, the form closes, then runs the logoff.

    here is the hidden form code.
    Code:
    sub form_unload()
     LogOffPC
    end sub


    this code goes in a module

    Code:
     
    
    Declare Function ExitWindowsEx& Lib "user32" (ByVal uFlags&, ByVal wReserved&)
     
     '//constants needed to exit Windows
    Global Const EWX_LOGOFF = 0
    Global Const EWX_SHUTDOWN = 1
    Global Const EWX_REBOOT = 2
    Global Const EWX_FORCE = 4
    
    
         '//log-off
    Sub LogOffPC()    
        call  ExitWindowsEx(EWX_LOGOFF, 0&)
    End Sub

  4. #4
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Stand corrected, nice ranman256!!

  5. #5
    redekopp is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2015
    Location
    Saskatoon
    Posts
    108
    This works practically perfect!
    Thank you

    The only issue I am noticing is that the database doesn't close before the log off happens so it sits with the "This program is preventing you from logging out" and the user would have to click Force Log Off. If they decided to hit cancel they could then in turn access the server.

    Thoughts?

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

Similar Threads

  1. Replies: 2
    Last Post: 11-28-2016, 12:33 PM
  2. Replies: 2
    Last Post: 12-20-2012, 03:06 PM
  3. Replies: 4
    Last Post: 11-29-2012, 12:45 AM
  4. Replies: 8
    Last Post: 04-07-2011, 05:52 AM
  5. TextBox Knows the Computer User
    By MFS in forum Access
    Replies: 7
    Last Post: 05-12-2009, 02:00 PM

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