Error shown while trying to log in by entering the code
I have just started with the visual basic programming. So, my concepts are not very clear. Please help me in making my learning a success. I actually want to build a login program in VB 6 using the Microsoft access database and an ADO control. My first step was to build a login form in VB. So, it was created successfully. The print screen of the created form is attached below:
Next, I created an access database, which I named database. In the login form, I added a ADO controller and named it ADO user. My next step was to set the ADO controller properties. I set them and the screenshot of the properties is attached below:
I also set the property of record source as shown below:
I wrote the following code, which I later added to the login button:
Private Sub cmdLogin_Click(Index As Integer)
Dim username As String
Dim psword As String
Dim userName As String
Dim pword As String
Dim Msg As String
username = txtName.Text
psword = txtPassword.Text
Do Until adoUser.Recordset.EOF
If adoUser.Recordset.Fields("userName").Value = username And adoUser.Recordset.Fields("pword").Value = psword Then
Msg = MsgBox("Invalid password, try again!", vbOKCancel) If (Msg = 1) Then
txtName.Text = ""
txtPassword = ""
When I try to log in by entering this code, I get an error on my screen. The print screen of the error is attached below:
In the above dialogue box, I pressed the debug button and on doing so, a line is highlighted in the code, which I have written. Please see the attached screenshot:
I have rechecked my code, but I cannot detect the root cause of the problem. Can anyone please tell me if my code is right or wrong? I have checked it again and again, but of no use.
Any help will be highly appreciated.
Looking forward to your suggestions.