Hello

I've been designing a Bookstore where students can login to their accounts and buy books.
And since then i've been struggling with this " error '424' Object required " and i i don't know how to fix it.
This starts at the beginning of the program at the login.

Here is my code:

Private Sub Command1_Click()

Dim str As String

studentid = Text1.Text
Password = Text2.Text
cond = False

str = "SELECT StudentID,Password From student ORDER BY StudentID ASC"
dataStudent.RecordSource = str "<=== I keep having error here
dataStudent.Refresh
datStudent.Recordset.MoveFirst

studentid = Text1.Text
Password = Text2.Text
cond = False

Do While Not dataStudent.Recordset.EOF And cond = False
 If dataStudent.Recordset.Fields("StudentID").Value = studentid Then
    If dataStudent.Recordset.Fields("Password").Value = Password Then
        
        Form2.Show
        Form1.Hide
        cond = True
    End If
End If
    dataStudent.Recordset.MoveNext
Loop
 
 If cond = False Then
   MsgBox = " Incorrect Login or Password"
 End If
 
End Sub

I keep getting error at line 10 altought the statement looks correct.
I'm desperate and don't know what to do.
Would welcome anything

Thanks

Recommended Answers

are u using DAO then first connect to the database and then to the table

if u r using ADO then when u end the "str" use the connection string to database there with relevant options such as adopendynamic,adlockoptimistic

Jump to Post

Im not the best at VB, but it seems that on line 3 when you declar Dim str as string. its recognizing str as a keyword. thats why it is saying object required on line 10. Your putting a keyword there, not a string object. Rename your str.

Jump to Post

All 5 Replies

are u using DAO then first connect to the database and then to the table

if u r using ADO then when u end the "str" use the connection string to database there with relevant options such as adopendynamic,adlockoptimistic

why r u making it so tedious....

simply open a connection string directly put in text1 and text2 in ur sql....if matches show form or quit. SIMPLE

i also actually need to load the whole line in the database.

Im not the best at VB, but it seems that on line 3 when you declar Dim str as string. its recognizing str as a keyword. thats why it is saying object required on line 10. Your putting a keyword there, not a string object. Rename your str.

Dear sir

with my little experience of Vb I m pleased to inform U that the "str" is actually function and can not be used as U have done in line 3. Instead of str u can use any other word like st, srt, mystr etc...
Surely this will help U.

with regards

Bashir Ahmad

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.