Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2005
    Posts
    102

    Unanswered: Remember who the current user is

    Hi guys,

    I have a startup form that prompts user to login, the values from this form are from a table (table of users).
    Code:
    Private Sub cmdLogIn_Click()
    If LOGIN1 = 1 Then
        Do While flag = False
           If txtUserName.Value = User.Value And txtUserPass.Value = Password.Value Then
                flag = True
                MsgBox "Welcome " & User.Value & " to Inventory Tracer 2.01"
                DoCmd.Close
                DoCmd.OpenForm "Main Switchboard"
            Else
                If User.Value <> "" Then
                    DoCmd.GoToRecord , , acNext
                Else
                    MsgBox "Please try again or contact your System Administrator"
                    DoCmd.GoToRecord , , acFirst
                    flag = True
                End If
            End If
        Loop
    Else
    Do While flag = False
       If txtUserName.Value = User.Value And txtUserPass.Value = Password.Value And txtLevel.Value >= 99 Then
            flag = True
            MsgBox "Welcome " & User.Value & " to Inventory Tracer 2.01"
            DoCmd.Close
            DoCmd.OpenForm "Administration"
        Else
            If User.Value <> "" Then
                DoCmd.GoToRecord , , acNext
            Else
                MsgBox "You don't have access System Administration", vbOKOnly, "Sorry"
                DoCmd.GoToRecord , , acFirst
                DoCmd.Close
                flag = True
            End If
        End If
    Loop
    End If
    End Sub
    When the user log's in successfully, I want the database to remember who that user is? So I can pull his/her name from any form I want. Just like how the CurrentUser() function works when using Access Security. The reason for this is I'm trying to create a audit table, and I want to be able to pull this name when I need to audit something. How do I begin?
    The only true wisdom is in knowing you know nothing.

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    If you have a form that will always be open (like a main menu), you can create a hidden textbox on that form and copy the info there.
    Paul

  3. #3
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Other options include but are not limited to:

    Create a "session" table to log who's logged in
    Store the current user in a global variable
    Pull the current user every time it's needed
    Create and instantiate a "User" class object
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Anything wrong with using the users network logon?.

    Its harder to fake, controlled by your network permsions, changed frequently as required, reasonably secure. One less password and userid for the user to remember, and is 'always on'.

    if you are interested do a google for Dev Ashish's API's, or look for a thread usingthe search 'network logon' and look for a block of code contributed by Paul AKA PKStormy.
    HTH
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Jun 2005
    Posts
    102
    Quote Originally Posted by healdem
    Anything wrong with using the users network logon?.
    HTH
    Thanks for the responses. Healdem, to answer your question. Yes there is a problem with using the network user's logon. The problem is, in our receiving dock, there are 5 Warehouse workers who all have network access and there's only 2 terminals (Workstation), that's why when they access the database, they could be accessing it through someone else's profile because they are so busy down there, they prefer to use only one or two account to run everything.
    The only true wisdom is in knowing you know nothing.

Posting Permissions

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