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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find Results Matching a Control

Status
Not open for further replies.

Joshman

Instructor
May 24, 2000
13
US
I have a form that is used to lookup a street name in a list of addresses. I have a combo box that just has street names in it and the form results is a list of actual addresses with street number and name.

I want the form to show me all of the addresses with the street name that I choose in the combo box. How do I do that?

Thanks
Joshman


joshuab@musician.org
joshuaweb.htmlplanet.com
 
Hi Joshman,
In the After Update event of your combo box something like this (fron F1 Help):

ApplyFilter Method Example

The following example uses the ApplyFilter method to display only records that contain the name King in the LastName field:

DoCmd.ApplyFilter , "LastName = 'King'"

As you might use this again and again, first add

DoCmd.runcommand accmdremovefiltersort

so you are always starting with all possible records. :) Gord
ghubbell@total.net
 
Here is what I would do .. under the row source in the properties of the combo box add a SQL statement to bring back a record set of what you want. For example

SELECT tableName.Fieldsyouwant, tblName.[Title]+" "+tblName.[FirstName]+" "+tblName.[LastName] AS ConCatName, tblName.Address, tblName.PostalCode/Zip FROM tblName WHERE (tblName.cbobox)like [Forms]![formname]![Street]) ORDER BY tblName.Street;

Course you would add appropriate names :)
Hope that helps some. It works well for me on filling up a form based on a combo box and then just use that record set generated to fill form.

Joanne
 
One thing I forgot to mention, I have my combo box in the From Header and the text fields I am populating in the Details section.

Joanne
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top