I'm doing a coursework project using Visual Basic 6, and I simply can't get the Login form to work. On my tutpor's reccomendation, I'm using an Adodc controller with the Jet 4.0 engine to connect to a database containing usernames, passwords and access levels for users. The connection works fine and I've tested it out, but I'm getting Runtime Error 91 every time I run the Logon form. Here's the code I'm using:
Private Sub Cancel_Button_Click()
Private Sub Login_Button_Click()
'Runtime 91 Error happens on the Line Below
If (Adodc1.Recordset(0) = txtUserName.Text And Adodc1.Recordset(1) = txtPassword.Text) Then
msgError.Caption = "Username or Password Incorrect"
Value is the default property and can be omitted in this instance.
The error indicates either the recordset is not initialized or one of the text boxes referenced does not exist by the name specified. My money is on the recordset object.
For an example on how to use ado code rather than the control use the data form wizard inside vb and choose ado code. This will generate the code to create the connection and the recordset object, connect to the database and initialize the recordset.
Did you look at my code? It is well-explained (based on feedback) and it WORKS. (Imagine that!)
If you can't see how I open a recordset, just press F8 to run the program, and step thru it line by line. Or else, press F9 on a line to set a BREAK POINT, and you can run up to that point, and then STEP thru the code.
You can see the actual value of variables by hovering the mouse while in DEBUG mode (stepping thru)