Search Button

C

Confused87

I created a search command button like this but it is not working , any ideas?

New command button, exit wizard, went to properties, change caption, went to
Event , clicked the ... On Click, selected Code Builder, deleted what was
there, copy/pasted the following, adjusted the [ ] so it had the right table
column.

Dim RetVal As String
RetVal = InputBox("Enter Surname")

If RetVal <> "" Then
Me.Filter = "[Surname] = '" & RetVal & "'"
Me.FilterOn = True
End If

Private Sub Command338_Click()

End Sub
 
B

BruceM

Put the code between Private Sub and End Sub

Private Sub Command338_Click()

Dim RetVal As String
RetVal = InputBox("Enter Surname")

If RetVal <> "" Then
Me.Filter = "[Surname] = '" & RetVal & "'"
Me.FilterOn = True
End If

End Sub

This should limit the recordset to just the records in which Surname equals
the input box value.

Another option is to use an unbound combo box instead of an input box. In
that way you can present the user with a list of names rather than having to
type the name.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top