Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make DB remember who is logged in 2

Status
Not open for further replies.

rodrunner79

IS-IT--Management
Dec 27, 2005
144
0
0
US
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?
 
I do not like the approach of having a custom login. There are many slipus in this approach, including making it WAY ro easy to circumvent. MS. Access security is reasonaly roubst and provides the CurrentUser. If you want all users to have all privledges, it is not even that hard to implement and use nad provides many other benefits, including the username.


Having gotten that out of my ()*&(*&^Y&^% ...

If you are at LEAST having the FE reside in hte local workstation, just add a boolean to the login table (blnCurrUser?). In the log in code, clear the field at the start of the routine and set the boolean for the successful user log in. There afger, it is a standard query for whom-ever the flag is set to true for?



MichaelRed


 
Just out of interest...

I use the windows registry..when the user logs in I store the username in the windows registry and read it from the registry whenever and wherever i need it. It survives going into form design and back again... plus it means i can store who last logged in on a per PC basis. If the same user always uses the same PC then i can pre-fill in the login box with their id...

Look at VBA functions GetSetting and SaveSetting, easy to use.

Regards

BuilderSpec

Hope this helps!

Regards

BuilderSpec
 
Hey thanks BuilderSpec, I will look into those functions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top