Error in searching a record
Hi I am receiving an error whenever i search for an ID. i have use input box and here are the code for the search...
Private Sub cmdSearch_Click()
Dim key As String, str As String
key = InputBox("Enter the Student No whose details u want to know: ")
Set rs = Nothing
str = "select * from student where ['s_no']= & key"
rs.Open str, adoconn, adOpenForwardOnly, adLockReadOnly
txtNo.Text = rs(0)
txtName.Text = rs(1)
txtDate.Text = rs(2)
txtTime.Text = rs(4)
txtPhone.Text = rs(3)
txtSection.Text = rs(5)
Set rs = Nothing
str = "select * from emp"
rs.Open str, adoconn, adOpenDynamic, adLockPessimistic
End Sub
the ID number should be 8 numbers but whenever i click search i am receiving this error:
Syntax error (missing operation) in query expression '['s_no']=&key'
FYI: i am using ms access as my database the field name for the student number is s_no and if you want the full code here it is: PLzz help.. THANKS IN ADVANCE
Re: Error in searching a record
Hi, Not sure without knowing the DB layout but probably need to change to....
str = "SELECT * FROM student WHERE [s_no]= " & key