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

Using radio buttons to query combobox

P: n/a
Hi. I have this Combobox name 'Origin' that contains all states and
countries. I would like to create two Radio buttons (State and
Country) that when you select State, the combobox will query only the
states and vice versa for country. I've create two columns in the
Origin table (OriginState and OriginCountry) and set the data type to
'bit' to differentiate the two. How would I query the combobox when a
radiobutton is selected? Thanks.

Sep 11 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Create a QryState that returns a list of the states and a QryCountry that
returns a list of the countries. Add an option group that contains two radio
bottons with labels State and Country to your form. The option group will
have a value of 1 for state and 2 for country. The option group will only
permit one button to be active. Put the following code in the AfterUpdate
event of the option group:
Select Case Me!NameOfYourOptionGroup
Case 1
Me!NameOfYourCombobox.Rowsource = "QryState"
Case 2
Me!NameOfYourCombobox.Rowsource = "QryCountry"
End Select

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
re******@pcdatasheet.com

"Eric" <er************@gmail.comwrote in message
news:11**********************@r34g2000hsd.googlegr oups.com...
Hi. I have this Combobox name 'Origin' that contains all states and
countries. I would like to create two Radio buttons (State and
Country) that when you select State, the combobox will query only the
states and vice versa for country. I've create two columns in the
Origin table (OriginState and OriginCountry) and set the data type to
'bit' to differentiate the two. How would I query the combobox when a
radiobutton is selected? Thanks.

Sep 11 '07 #2

P: n/a
On Sep 11, 10:57 am, " Steve" <so...@private.emailaddresswrote:
Create a QryState that returns a list of the states and a QryCountry that
returns a list of the countries. Add an option group that contains two radio
bottons with labels State and Country to your form. The option group will
have a value of 1 for state and 2 for country. The option group will only
permit one button to be active. Put the following code in the AfterUpdate
event of the option group:
Select Case Me!NameOfYourOptionGroup
Case 1
Me!NameOfYourCombobox.Rowsource = "QryState"
Case 2
Me!NameOfYourCombobox.Rowsource = "QryCountry"
End Select

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
resou...@pcdatasheet.com

"Eric" <eric.nguyen...@gmail.comwrote in message

news:11**********************@r34g2000hsd.googlegr oups.com...
Hi. I have this Combobox name 'Origin' that contains all states and
countries. I would like to create two Radio buttons (State and
Country) that when you select State, the combobox will query only the
states and vice versa for country. I've create two columns in the
Origin table (OriginState and OriginCountry) and set the data type to
'bit' to differentiate the two. How would I query the combobox when a
radiobutton is selected? Thanks.
Make sure you requery the combo box after running Steves code.
Me!NameOfYourCombobox.Requery

Sep 11 '07 #3

P: n/a
lg********@gmail.com wrote:
On Sep 11, 10:57 am, " Steve" <so...@private.emailaddresswrote:
>>Create a QryState that returns a list of the states and a QryCountry that
returns a list of the countries. Add an option group that contains two radio
bottons with labels State and Country to your form. The option group will
have a value of 1 for state and 2 for country. The option group will only
permit one button to be active. Put the following code in the AfterUpdate
event of the option group:
Select Case Me!NameOfYourOptionGroup
Case 1
Me!NameOfYourCombobox.Rowsource = "QryState"
Case 2
Me!NameOfYourCombobox.Rowsource = "QryCountry"
End Select

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
resou...@pcdatasheet.com

"Eric" <eric.nguyen...@gmail.comwrote in message

news:11**********************@r34g2000hsd.google groups.com...

>>>Hi. I have this Combobox name 'Origin' that contains all states and
countries. I would like to create two Radio buttons (State and
Country) that when you select State, the combobox will query only the
states and vice versa for country. I've create two columns in the
Origin table (OriginState and OriginCountry) and set the data type to
'bit' to differentiate the two. How would I query the combobox when a
radiobutton is selected? Thanks.


Make sure you requery the combo box after running Steves code.
Me!NameOfYourCombobox.Requery
Setting a new rowsource essentially does a requery. However, one might
want to clear out the current value of the combo.
Sep 11 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.