Users in login

G

Guest

some help guys . I have a project in access 2003 where the users are required
to login using the login form. When using the project I wan't the forms to
reflect the users name on any textbox where a user name is required without
typing it or selecting. The user is automatically assigned on login .Am using
this code but instead its giving me the person using the computer not the one
logged in my software . Any help people Doug or Arvin or anybody else out
there

Public Function GetUser() As String
'return currently logged in user
Dim db As New Application
GetUser = db.CurrentUser
End Function
 
G

Guest

Look in your Login form's code and see if the current user is being stored in
a variable somehow...the code there should give you an idea how to proceed.

Steve
 
G

Guest

SteveM said:
Look in your Login form's code and see if the current user is being stored in
a variable somehow...the code there should give you an idea how to proceed.

Steve
Am using this code to get the user logged in
Dim stDocName As String
Dim stLinkCriteria As String

Dim a As String
Dim b As String
Dim c As String
Dim d As String
Dim e As String
Dim f As String
a = ""
b = ""
c = ""
d = ""
e = ""
f = ""

If UserName = b And Password = a Then
stDocName = ""
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "Login"
ElseIf UserName = c And Password = d Then
stDocName = ""
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "Login"
ElseIf UserName = e And Password = f Then
stDocName = ""
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "Login"

Else
MsgBox "Invalid Password, try again!", , "ACCESS DENIED"
Password.SetFocus

where a,b,c are the user names and d,e,f their passwords
User band c have access to only certain forms and a is the admin
Where am I getting wrong and can someone help with the code
 
R

Rick Brandt

Muriukis said:
Am using this code to get the user logged in
Dim stDocName As String
Dim stLinkCriteria As String

Dim a As String
Dim b As String
Dim c As String
Dim d As String
Dim e As String
Dim f As String
a = ""
b = ""
c = ""
d = ""
e = ""
f = ""

If UserName = b And Password = a Then
stDocName = ""
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "Login"
ElseIf UserName = c And Password = d Then
stDocName = ""
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "Login"
ElseIf UserName = e And Password = f Then
stDocName = ""
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "Login"

Else
MsgBox "Invalid Password, try again!", , "ACCESS DENIED"
Password.SetFocus

where a,b,c are the user names and d,e,f their passwords
User band c have access to only certain forms and a is the admin
Where am I getting wrong and can someone help with the code

All of your variables are set to "". The code as posted is gibberish. There is
also nothing that indicates where UserName and Password come from nor how they
got their values assigned.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top