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

Making a form control the criteria for the sql statement of another control (Access 2003)

P: n/a
I have two comboboxes on a form. Combobox1 uses field1 in another table
as its source of data. What I want to do is to enable combobox2 to use
field2 in that table, but only to show the rows of data that contain
the item selected in combobox1.

At the moment I can easily write a SQL statement with a WHERE clause,
but I only know how to specifiy static criteria. What I want is a
variable criteria, where the criteria is the data contained in combobox
1.

Is this possible?

thanks for any help :)

Ste

Nov 20 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"SteMc" <go****@jasmonio.supanet.comwrote
>I have two comboboxes on a form. Combobox1 uses field1 in another table
as its source of data. What I want to do is to enable combobox2 to use
field2 in that table, but only to show the rows of data that contain
the item selected in combobox1.

At the moment I can easily write a SQL statement with a WHERE clause,
but I only know how to specifiy static criteria. What I want is a
variable criteria, where the criteria is the data contained in combobox
1.
In the AfterUpdate event of ComboBox1, specify the Row Source of ComboBox2
as a SELECT query. So if the first combo selects the state, then the second
combo of cities is filtered by that state:

Private Sub cboState_AfterUpdate()
Me!cboCity.RowSource = "SELECT city_id, cty_name FROM city WHERE
city_state = ' " & Me!cboState & " ' "
Me!cboCity.Requery
End Sub

--
Darryl Kerkeslager
Nov 20 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.