Filter Combobox with Value List Type (1 Viewer)

shafara7

Registered User.
Local time
Today, 23:41
Joined
May 8, 2017
Messages
118
Hi, I know I have posted something similar before this (link below) but this time it is quite different.

https://www.access-programmers.co.uk/forums/showthread.php?t=293754&highlight=list+filter

In this new case, I have a combobox with value list type and an option button that will filter the value inside the combobox.
For example, my cboCountry has the following value:
1; China; 2; Belgium; 3; Italy; 4; India; 5; Spain; 6; Portugal...
And my option button named optAsia will filter the countries to only Asian country when it's checked.
I want it to only show:
1; China; 4; India
when the optAsia in checked.

Is there any VBA code for this to make it possible?
 

isladogs

MVP / VIP
Local time
Today, 22:41
Joined
Jan 14, 2017
Messages
18,209
Create a table with country & continent as fields then use that for your record source for each item
 

shafara7

Registered User.
Local time
Today, 23:41
Joined
May 8, 2017
Messages
118
I know that if the combobox is a Table/Query type.
But mine is Value List type.
 

isladogs

MVP / VIP
Local time
Today, 22:41
Joined
Jan 14, 2017
Messages
18,209
I realise that. You'll have to change it.

I'm sure Access doesn't happen to know which continent every country is in!
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 22:41
Joined
Jul 9, 2003
Messages
16,269
Colin is pointing you in the right direction there.

I suppose you could write something in VBA but where would you begin? Even thinking about the possibility is giving me a headache!

To solve your problem you need to store information and that's exactly what MS Access is brilliant at. You are going to need to store the information for the country and the continent in a "country" table.

So your country table would have at least three Fields, one for the ID, one for the name of the country and another to identify the continent. This is usually done with an integer field a number not text.

This continent identifier would point to another table containing a list of continents.

Now you have said you want to have an option group. To link the continents in the table to an option group might be a bit of a challenge. In other words a much simpler method is to have the Continents listed in a combobox and then use the selected value from the continent combobox to control the list displayed in the country combobox.

Sent from my SM-G925F using Tapatalk
 
Last edited:

shafara7

Registered User.
Local time
Today, 23:41
Joined
May 8, 2017
Messages
118
I was thinking of a code that will only show the value that we want
such as cboCountry.value = 1, 4 ... (for example) but I am not sure if such codes exist.

I thought about that option group too. I am mot sure how it will group together the records. So maybe I should just change to combobox instead on option group.

But whether or not I use the option group or combobox, I still have to look for the vba codes like the example above.
 

isladogs

MVP / VIP
Local time
Today, 22:41
Joined
Jan 14, 2017
Messages
18,209
It is reasonable to expect Access to understand data that won't change e.g. calendar dates

However countries do change and so any list (if it does exist) won't remain the same over time.
For that reason, its not going to be built into Access.
Also some countries are in more than one continent e.g. Turkey is in both Europe & Asia so would need 2 records.

You may be able to download a list of countries & continents if you search the net.
No matter whether you use an option group or combo box (better) for continents you will still need to store the data in a table
 

Users who are viewing this thread

Top Bottom