Hello,
I have a table of pupils names and a form to view the data.
What I want is a command button which would accept a surname to search for and then find the matches of that surname
I guess a start would be to find the firstmatch so I tried the following code
Private Sub cmdsearchbyname_Click()
Dim searchname As String
searchname = InputBox("Enter name to search for")
tblmembers.Recordset.FindFirst "[surname]=" & searchname
If tblmembers.Recordset.NoMatch Then
MsgBox ("No matches found for " & searchaname)
End If
End Sub
the table i am searching is called tblmembers and the field that I want to search is surname
When I run this I get the following error
run time error 424 object required
on this line
tblmembers.Recordset.FindFirst "[surname]=" & searchname
Any help would be greatly appreciated
I will deal with the problem of multiple matches later!
Thanks
I have a table of pupils names and a form to view the data.
What I want is a command button which would accept a surname to search for and then find the matches of that surname
I guess a start would be to find the firstmatch so I tried the following code
Private Sub cmdsearchbyname_Click()
Dim searchname As String
searchname = InputBox("Enter name to search for")
tblmembers.Recordset.FindFirst "[surname]=" & searchname
If tblmembers.Recordset.NoMatch Then
MsgBox ("No matches found for " & searchaname)
End If
End Sub
the table i am searching is called tblmembers and the field that I want to search is surname
When I run this I get the following error
run time error 424 object required
on this line
tblmembers.Recordset.FindFirst "[surname]=" & searchname
Any help would be greatly appreciated
I will deal with the problem of multiple matches later!
Thanks