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

Binding username to query if password is true

Status
Not open for further replies.

tinmar

Technical User
Mar 24, 2003
55
0
0
HK
Hi People,

I have created a username/password form, i want to know for instance if the password is correct, how do i make the username bind to a parameter in a query?

so the username = "mark" and password = "abc", how do i make it so that in the query, the username will then only query the data which has "mark" associated to it

thanks
 
You may use something like Forms![your username/password form]![ your username control] as a criteria in your query.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
query the data which has "mark" associated to it"
Are you saying you have user’s password associated with records?

Have fun.

---- Andy
 

Andy - I think he has the user NAME associated with records.

tinmar - upon successful login, save the user name to a variable in a module that can be accessed from the queries.


Randy
 
Sorry guys, let me be a bit more specific in the stuff i have since I'm a real noobie with Access. So i have a login form with the below

Private Sub Command4_Click()
Username.SetFocus
If Username = "00897" And Password = "next" Then
MsgBox "Username & Password Validated"
DoCmd.Close
DoCmd.OpenForm "Combined_Query_Jan"
Else
MsgBox "Please re-enter your Username and Password."
End If
End Sub

So if the username and password currently is correct it will go to another form "combined_Query_Jan". So what I am trying to do is to somehow bind the above username to the criteria box in a query field which is contained in the "combined_Query_Jan". So when the person enters the correct username and password they will go to the combined_Query_jan which will only contain this persons info.

Hopefully this makes a bit more sense to what I am trying to retrieve

thanks
 
If you simply hide your form rather than closing it, the values in the Username text box will be available in queries, code, etc.

I always use "Me." to reference a control on a form. This avoids some confusion between control and variable names.

Code:
Private Sub Command4_Click()
[COLOR=#4E9A06]'     Username.SetFocus Don't need to do this[/color]
    If Me.Username = "00897" And Me.Password = "next" Then
        MsgBox "Username & Password Validated"
        Me.Visible = False
        DoCmd.OpenForm "Combined_Query_Jan"
      Else
        MsgBox "Please re-enter your Username and Password."
    End If
End Sub

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top