cigarprofiler
Registered User.
- Local time
- Yesterday, 17:53
- Joined
- Mar 25, 2017
- Messages
- 32
Here's what I'm trying to do:
I have an unbound login form that looks up credentials in tbl_users. So far, so good, thank you Google, this forum and copy-paste.
The match is made on user name and password, but I also want to retrieve the userid and put it in a textbox on the login form. Here's what I tried so far (in bold):
I have tried to set the control source of txt_userid to str_userid but that doesn't work (it's not an option in the drop-down and if I do =str_userid it converts to =[str_userid] and puts #NAME? in the textbox).
Can someone give me a hint?
I have an unbound login form that looks up credentials in tbl_users. So far, so good, thank you Google, this forum and copy-paste.
The match is made on user name and password, but I also want to retrieve the userid and put it in a textbox on the login form. Here's what I tried so far (in bold):
Code:
Private Sub btn_login_Click()
Dim rs As Recordset
[B]Dim str_userid As String[/B]
Set rs = CurrentDb.OpenRecordset("public_tblusers", dbOpenSnapshot, dbReadOnly)
rs.FindFirst "username='" & Me.txt_user_name & "'"
If rs.NoMatch Then
Me.lbl_user_not_found.Visible = True
Me.txt_user_name.SetFocus
Exit Sub
End If
Me.lbl_user_not_found.Visible = False
' look-up column userid from public_tblusers that belongs to the username
' and put it in txt_userid on the open login form
[B]str_userid = rs!userid[/B] ' QUESTION: how do I put it in txt_userid?
If rs!userpassword <> Nz(Me.txt_password, "") Then
Me.lbl_password_incorrect.Visible = True
Me.txt_password.SetFocus
Exit Sub
End If
Me.lbl_password_incorrect.Visible = False
DoCmd.OpenForm "frm_review"
Me.Form.Visible = False
End sub
I have tried to set the control source of txt_userid to str_userid but that doesn't work (it's not an option in the drop-down and if I do =str_userid it converts to =[str_userid] and puts #NAME? in the textbox).
Can someone give me a hint?
Last edited: