How to store username from a login page - New Programmer!

  • Thread starter Thread starter arachief
  • Start date Start date
A

arachief

Guest
Hi,

Pls i am having some problems storing the logged in username in a variable. I am creating my own login page (not using the security in Access). I have a login page and another form for changing password. Pls how do i carry forward the logged in username so the right record can be updated? I tried using CurrentUser() but it keeps giving me 'admin'.

Kindly help. Thanks in advance.
 
Hi,
"Admin" is what you open Access as by default (using system workgroup). For information relating to Access workgroups and security please search the forum.

If you declare the username as a public variable you may have problems if someone else opens the database and changes the value of the variable (not sure if Access uses session level variables)

Anyway, a solution I have used in the past is to have a user table (TblUser) where you set up your users. Each user has a unique UserID and within their user record you store their network username i.e. jbloggs

You can then create a function such as:
Public Function GetUserID()
GetUserID = Dlookup ("[UserID]", "TblUsers", [Username]=" & Environ("Username")"")
End Function

This will look up their network username in the TblUsers table and return the relative userID. You can then just call GetUserID whenever you need it.

Hope that helps
BF
 
Last edited:

Users who are viewing this thread

Back
Top Bottom