Results 1 to 5 of 5
  1. #1
    Join Date
    May 2007
    Posts
    92

    Unanswered: Login Time / Logout Time

    Hi Everyone,

    Can anyone tells me what wrong with my Login Time and Logout Time problem?

    Here is my application like..

    I have a logon form and once the user click the "Login" button in the form, their network name and login time is capture.

    And when the user clicks the "Exit" button in the other form, their logout Time is captured.

    However, the network name and Login Time are stored in the 1st line of the row but the Logout is stored in the 2nd line of the row.

    How can i make it all the data stored in 1 line instead of both lines?

    Here my codes

    In the Login Button

    Set db = CurrentDb
    Set rst = db.OpenRecordset("LoginTable")


    With rst
    .AddNew
    !EmployeeName = cboEmployee
    !Name = fGetFullNameOfLoggedUser()
    !LoginUser = WindowsUserName()
    !LoginTime = Now()
    .Update
    End With

    rst.Close
    Set rst = Nothing

    In the Exit button

    Set db = CurrentDb
    Set rst = db.OpenRecordset("LoginTable")
    With rst
    .AddNew
    !LogoutTime = Now()
    .Update
    End With


    rst.Close
    Set rst = Nothing
    Thank..

  2. #2
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Hi

    How about

    In the Exit button

    Set db = CurrentDb
    Set rst = db.OpenRecordset("SELECT LogOutTime FROM LoginTable WHERE LoginUser = " & WindowsUserName() & " AND LoginTime = " & DMax("LoginTime","LoginTable","LoginUser = " & WindowsUserName()))
    With rst
    .Edit 'I THINK YOU NEED THIS WITH DAO!?
    !LogoutTime = Now()
    .Update
    End With

    You can actually do all this with action queries, and I am sure someone could come up with a little smarter SQL that this, but life too short!


    MTB

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Did you make any effort to understand the previous answers to your question

    in simple terms the reason why you are not getting the log in log out ont he same line is that you are adding a new record for each event

    to get them one one line you MUST update the logon record with the logoff. to do that you need to know what makes the logon record unique (The primary key for the logon/off table), or you could take a flyer and assume that you update the last non null logoff for a specified user and computer

    You have already had references to the API calls & PKStormy's user functions that will tell you who is looged on on what computer they are using.

    if you need furthjer assistance I'd sugegst going to a school or after hours college possibly w3schools.com and learn soemthign about Access before trying to be too ambitious
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    May 2007
    Posts
    92

    Login Time / Logout Time

    Hi MikeTheBike,

    I encounter the problem of the "You have cancel the previous operation" Error "2001". How should I solve this problem?

    Thank..

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Steven....
    READ healdems reply.

    I'm not willing to contribute to solving your problem unless
    1. You can justify your need to implement this
    2. You listen to all replies and not chose to ignore ones you don't like the sound of
    3. You show a willingness to learn
    4. You at least try to debug the problem before running back here

    Sorry for the rant, but this is not the first time!
    George
    Home | Blog

Posting Permissions

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