+ Reply to Thread
Results 1 to 5 of 5

Automatic Logout

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-07-2015
    Location
    Halifax, NS
    MS-Off Ver
    365
    Posts
    100

    Question Automatic Logout

    Hello, I have a workbook that requires users to login. The user information is stored on a sheet named "Login". The sheet contains lists. One list shows user names and passwords, another records the date and time that users login and another list (field) shows the current user. When the user logs out the current user field is set to blank (" "). I want this field to default to " " if the user fails to logout.
    The field in question is on sheet "Login" and at P8.

    I used this code to clear the field before close but it doesn't work. However the same line of code on the workbook_open works fine. Does anyone know why this is? Not that it should matter but the logic in my brain says that the logout should occur on close and not on open.

    This does not work
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Worksheets("Login").Cells(8, 16) = " "
    End Sub
    This works
    Private Sub Workbook_Open()
    Worksheets("Login").Cells(8, 16) = " "
    End Sub

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,431

    Re: Automatic Logout

    .
    .
    It works here.


    Are you certain you are entering data into P8 and not P16 ?

  3. #3
    Forum Contributor
    Join Date
    04-07-2015
    Location
    Halifax, NS
    MS-Off Ver
    365
    Posts
    100

    Re: Automatic Logout

    Thank you for your reply. Yes the data is in P8. If the code works when the workbook opens, shouldn't it also work when the workbook closes?

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,431

    Re: Automatic Logout

    .
    .
    Running the attached will demonstrate your code functions as designed :
    Attached Files Attached Files

  5. #5
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,431

    Re: Automatic Logout

    .
    .
    Running the attached will demonstrate that your code does function as desired.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Login and Logout Template
    By carlzilla in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-06-2020, 10:55 AM
  2. Login/logout hrs - is there a quicker way?
    By jeffa0 in forum Excel General
    Replies: 3
    Last Post: 05-10-2016, 09:25 PM
  3. Login - Logout report
    By vamshi57 in forum Excel General
    Replies: 9
    Last Post: 04-19-2016, 12:38 AM
  4. Replies: 0
    Last Post: 02-17-2014, 07:44 AM
  5. [SOLVED] Macro to get the first and the last logout
    By Ca5m in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-22-2012, 02:09 PM
  6. How do I logout?
    By Bellzemos in forum The Water Cooler
    Replies: 4
    Last Post: 01-23-2010, 12:17 PM
  7. [SOLVED] First login & last Logout
    By Vikky in forum Excel General
    Replies: 2
    Last Post: 08-19-2006, 01:20 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1