Im using vb and access to for my project. Im trying to use this code in order to show all the payments made to a specific staff.
[CODE=vb]Private Sub Command1_Click( )
Dim strSQL As String
strSQL = "SELECT * FROM Staff "
strSQL = strSQL & "WHERE Firstname = " & txtName.Text
Set dbmyDB = OpenDatabase("E :\skol\A2 Computing\Speed y Pizza database.mdb")
Set rsStaff = dbmyDB.OpenReco rdset(strSQL, dbOpenDynaset)
If Not rsStaff.EOF Then rsStaff.MoveFir st
lstRecord.Clear
Do Until rsStaff.EOF
lstRecord.AddIt em rsStaff!Firstna me & " " & rsStaff!Lastnam e & vbTab & rsStaff!StaffID
lstRecord.ItemD ata(lstRecord.N ewIndex) = rsStaff!StaffID
rsStaff.MoveNex t
Loop
End Sub[/CODE]
I keep getting an error on the line " Set rsStaff = dbmyDB.OpenReco rdset(strSQL, dbOpenDynaset)" . It says 'Too few parameters. Expected one'
Im not very good with SQL statements so it's hard for me to solve. I would appreciate it if anyone has any good answers.
THANK U
[CODE=vb]Private Sub Command1_Click( )
Dim strSQL As String
strSQL = "SELECT * FROM Staff "
strSQL = strSQL & "WHERE Firstname = " & txtName.Text
Set dbmyDB = OpenDatabase("E :\skol\A2 Computing\Speed y Pizza database.mdb")
Set rsStaff = dbmyDB.OpenReco rdset(strSQL, dbOpenDynaset)
If Not rsStaff.EOF Then rsStaff.MoveFir st
lstRecord.Clear
Do Until rsStaff.EOF
lstRecord.AddIt em rsStaff!Firstna me & " " & rsStaff!Lastnam e & vbTab & rsStaff!StaffID
lstRecord.ItemD ata(lstRecord.N ewIndex) = rsStaff!StaffID
rsStaff.MoveNex t
Loop
End Sub[/CODE]
I keep getting an error on the line " Set rsStaff = dbmyDB.OpenReco rdset(strSQL, dbOpenDynaset)" . It says 'Too few parameters. Expected one'
Im not very good with SQL statements so it's hard for me to solve. I would appreciate it if anyone has any good answers.
THANK U
Comment