Error shown while trying to log in by entering the code

Asked By 0 points N/A Posted on -

Hi guys,

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
Exit Sub

End If

Msg = MsgBox("Invalid password, try again!", vbOKCancel) If (Msg = 1) Then
txtName.Text = ""
txtPassword = ""

End If
End Sub

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.

Kindest regards.

Answered By 0 points N/A #148290

Error shown while trying to log in by entering the code


Hello Carlos,

If you have checked the code and verified that there are no problems that could be causing the error you are getting, I will suggest that you try the following. But before that I will recommend that you check the code for any misspellings and mistakes in the commands that you are using for that could cause the problem like the one you are getting right now.

  • Otherwise it could be the VB application that is malfunctioning.
  • You will need to shut it down and all its processes it is running and then restart it and see if that will resolve the issue.
  • To shut down VB and all its processes, you will need to open the Task Manager and then go to process and end the VB process from there.



Login/Register to Answer

Related Questions