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

Similar Threads

Errors 2448 and 3075! 1
search command 1
Turn a filter off 1
Open a file 1
Open a file 13
Search function issue using Textbox and Listbox 3
data access page search code 1
Errors when trying to filter 3

Top