jumbledore
Active Member
- Joined
- Jan 17, 2014
- Messages
- 262
Hi,
I have created a database in access with a table and a form. the table contains usernames and passwords. the form contains 2 textboxes and 1 button. The user has to enter his userid and the password in the respective text boxes and then click on the button. What then happens is that the click event runs a vba code which runs an sql query to match the username in the textbox to the username in the table and then displays the corresponding password in a msgbox. But whenever I run the code I get an error. Below is the code. I would appreciate it if you could help me correct my errors. Thanks
***
passwords is a table with 2 columns, Username and Password
I have created a database in access with a table and a form. the table contains usernames and passwords. the form contains 2 textboxes and 1 button. The user has to enter his userid and the password in the respective text boxes and then click on the button. What then happens is that the click event runs a vba code which runs an sql query to match the username in the textbox to the username in the table and then displays the corresponding password in a msgbox. But whenever I run the code I get an error. Below is the code. I would appreciate it if you could help me correct my errors. Thanks
Code:
Private Sub Command4_Click()
Dim myRecordSet As New ADODB.Recordset
myRecordSet.ActiveConnection = CurrentProject.Connection
myRecordSet.Open "SELECT passwords.Password FROM passwords WHERE (((passwords.Username)=[Forms]![passwordform].[Usertext]))"
MsgBox myRecordSet.Fields(0).Value
myRecordSet.Close
Set myRecordSet = Nothing
End Sub
passwords is a table with 2 columns, Username and Password
Last edited: