Search Button

  • Thread starter Thread starter Confused87
  • Start date Start date
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
 
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.
 
Back
Top