ComboBox Filter

T

Tweety2005

I have form INITIAL where I choose a city, and with the code below..... when
it opens form MAIN filter all the registries pertaining to that city...

What I need:

On the MAIN form, I have a ComboBox, that also needs that filter
automatically by the city that has been chosen in the INITIAL Form, that is
to say, the CB rightnow shows the complete list of cities, but I need only
shows to me the city that was chosen in form INITIAL...


note: The CB take the data from a table Cities (ID, DESCRIPTION)
 
R

Roger Carlson

As long as the INITIAL form stays open behind the MAIN form, all you need to
do is have a WHERE clause in the RecordSource of the form that references
the selected city on the INITIAL form. You'll also have to add a WHERE
clause to the RowSource query of the Combobox.
On my website (www.rogersaccesslibrary.com), is a small Access database
sample called "ParaQuerySelect.mdb" which illustrates how to do this.

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
A

Allen

In the Form_Open event, set the RowSource of the combobox. As you set
the RowSource, use the Filter of the current form. For example.

ComboBox.RowSource = "SELECT City FROM TableName WHERE " & Me.Filter

For examples of setting the RowSource on the fly like this, download
the Access Tools demo at http://www.aislebyaisle.com/access/tools1.htm
and look at the VBA code behind some of the forms.
 
Top