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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting up Username and password

Status
Not open for further replies.

oraclejunior

Technical User
Jul 8, 2003
111
GB
Hi,

I have created a database to record risks, I want this to be accessed by unsername and password (each user having their own username and password).

When a risk is created and saved(using unbound forms) I want the record to also collect their usernameID.

How do I do this?

Thank you.

 
Hi!

You can use the Environ("username") function to return the windows user name. You can store that in a field in the table so each record will have the name of the user who imput the record.

You can also use the environ command to limit access to the database. If you have a for that automatically opens when the db opens you can use this in the load event.

Dim rst As DAO.Recordset

Set rst = CurrentDb.OpenRecordset("Select * From tblUsers Where WindowName = '" & Environ("username") & "'")

If rst.EOF = True and rst.BOF = True Then
MsgBox "You do not have permission to use this database. Please contact the system administrator to be granted access."
Application.Close
End If

Set rst = Nothing

You will need to set up a table of user names and keep it current.

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 

Instead of Environ("UserName")
Code:
Dim objWscript As Object
Set objWscript = CreateObject("Wscript.Network")
Dim TheComputer As String, UserDomain As String, UserName As String
TheComputer = objWscript.ComputerName
UserDomain = objWscript.UserDomain
UserName = objWscript.UserName
Set objWscript = Nothing

But if you concider user-level security from access you could also use the CurrentUser method to return the name of the current user of the database.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top