By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,965 Members | 1,355 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,965 IT Pros & Developers. It's quick & easy.

Searching a List Box by typing in a text box

P: 1
Hi Everyone.

I am looking for some help to add a search capability to my Access Form.

My form is based on a query of company names.

Initially, the form was set up that I would select the company name from the list box and data from the tables would come up in subforms based in three different tabs.

My database has grown and now I would like to add a text box to search the list box.

I am not that experienced writing any kind of code, can someone help me out?

Thanks.
Mar 15 '07 #1
Share this Question
Share on Google+
1 Reply


MMcCarthy
Expert Mod 10K+
P: 14,534
Hi Everyone.

I am looking for some help to add a search capability to my Access Form.
My form is based on a query of company names.

Initially, the form was set up that I would select the company name from the list box and data from the tables would come up in subforms based in three different tabs.
Assuming listbox name is List0. Put a command button (cmdSearch) on the form to filter the results of the subforms as follows:
Expand|Select|Wrap|Line Numbers
  1. Private cmdSearch_Click()
  2.     Dim strFilter As String, strOldFilter As String
  3.  
  4.     strOldFilter = Me.Filter
  5. If Not IsNull (Me!List0) Then _
  6.    strFilter = "[CompanyName]='" & Me!List0 & "'" 'Assumes each table has a company name field.
  7. End If
  8.  
  9. If strFilter > "" Then
  10.    Me![SubformName1].Filter = strFilter ' put name of subform in
  11.    Me![SubformName1].FilterOn = (strFilter > "")
  12.    Me![SubformName2].Filter = strFilter ' put name of subform in
  13.    Me![SubformName2].FilterOn = (strFilter > "")
  14.    Me![SubformName3].Filter = strFilter ' put name of subform in
  15.    Me![SubformName3].FilterOn = (strFilter > "")
  16.     End If
  17.  
  18. End Sub

My database has grown and now I would like to add a text box to search the list box.
Not sure I understand what you're looking for here.

Mary
Mar 17 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.