Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search by drop down list

Status
Not open for further replies.

djb1986

Technical User
May 22, 2010
1
US
I'm new to Access and I'm trying to create a searchable form. You select the field you want to search by using a drop down list, type the text into a text box and then search.

I've had no luck. Any help?

formsearch.jpg
 
The results from your field combo box and the text box can be combined to create a filter that can be applied to the form.
Code:
   dim strFilter as String
   If Not IsNull(Me.cboField) and _
         Not IsNull(Me.txtSearch) Then
      strFilter = "[" & Me.cboField & "] = """ & _
         me.txtSearch & """""
      Me.Filter = strFilter
      Me.FilterOn = True
    Else
      Me.FilterOn = False
   End If
This assumes your fields are text and you want an exact match. If you want different, you need to specify it.


Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top