Is it possible to filter a combo box (being used for finding records in a form)
according to the selection in an option group? In other words, when a user makes a selection in an option group which applies a filter, I want to restrict the choices in the combo box as well.
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Combo and Option Group
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Combo and Option Group
- This topic has 7 replies, 2 voices, and was last updated 24 years, 3 months ago.
AuthorTopicWSPlainsman
AskWoody LoungerFebruary 26, 2001 at 12:04 am #353281Viewing 0 reply threadsAuthorReplies-
WScharlotte
AskWoody LoungerFebruary 26, 2001 at 1:28 am #516282Sure, but how you do it depends on the rowsource for the combobox. If you use a saved query, you can reference the form’s option group in the criteria of the query and all you need to do is requery the combobox in the afterupdate event of the option group. If you use a select statement as the rowsource, you can modify it in code in the afterupdate event of the option group and set the combobox rowsource to the new select statement.
-
WSPlainsman
AskWoody LoungerFebruary 26, 2001 at 11:36 pm #516387I used a query so your first suggestion worked great except I can’t get it to show all records. Following is the criteria statement I put in the query. What’s wrong with the ending?
IIf([Forms]![MusicbyLevel]![LevelOptions]=1,”A”,(IIf([Forms]![MusicbyLevel]![LevelOptions]=2,”B”,(IIf([Forms]![MusicbyLevel]![LevelOptions]=3,”C”,(IIf([Forms]![MusicbyLevel]![LevelOptions]=4,”D”,*)))))))I also had difficulty getting it to requery using docmd but got that fixed (thus the edit).
-
WScharlotte
AskWoody LoungerFebruary 27, 2001 at 7:06 am #516444Well, what’s wrong with the ending is the asterisk. When you use an asterisk with an equal sign, you’re telling it to return all fields that contain nothing but an asterisk. If you want to use it to return anything, you have to use the Like operator. You could also speed up your comparison by using the choose() function. I’d rewrite it like this:
Like Choose([Forms]![MusicbyLevel]![LevelOptions],”A”,”B,”C”,”*”)
This assumes that MusicbyLevel will always contain a number of 1 or greater. If it’s possible that it might contain a zero, change it to this:
Like Choose([Forms]![MusicbyLevel]![LevelOptions] + 1,”*”,”A”,”B,”C”,”*”)
-
WSPlainsman
AskWoody Lounger -
WScharlotte
AskWoody LoungerMarch 1, 2001 at 1:57 am #516794Assuming your form was actually open, want to bet you’ve got a zero or a null value in there somewhere in [Forms]![MusicbyLevel]![LevelOptions]? Choose can only handle numbers as its index, and they have to start with one, which is why my expression was:
Like Choose([Forms]![MusicbyLevel]![LevelOptions] + 1,”*”,”A”,”B,”C”,”*”)
… which allows it to handle zeros and anything outside the range of 1,2 or 3.
If the field is a string with a number in it, you could use this:
Like Choose(Val([Forms]![MusicbyLevel]![LevelOptions]) + 1,”*”,”A”,”B,”C”,”*”)
If it might contain a null (bad design, naughty), you could use this:
Like Choose(Val(nz([Forms]![MusicbyLevel]![LevelOptions],0)) + 1,”*”,”A”,”B,”C”,”*”)
That would allow it to handle numbers or numeric strings, including null and zero values.
-
WSPlainsman
AskWoody LoungerMarch 2, 2001 at 3:06 am #517016Nove of the fields themselves contained a null value but the else statement in my options group code I wrote did contain a null statement (“gulp”). Putting the +1 at the beginning of the Choose statement fixed that. I don’t quite understand why it would not requery, why it worked for only the first option I picked, or what purpose the asterisk has. Please forgive my ignorance. I’m self taught and only been at it for a few months.
Nevertheless, my sincere thanks to charolotte for your patience and clear explanations. Everything is working fine now.
-
WScharlotte
AskWoody LoungerMarch 2, 2001 at 7:21 am #517040The Choose() function has a numeric index normally passed in as a field value or a variable and a list of alternative values to which the index is applied. Since there is no way to select item zero in a list or to select an absence of a value, which is what Null would be, you have to tweak the function a bit to handle zeros or nulls.
By adding one to the field value passed into Choose, you can force a zero field value to pick the first item in the list, but you need to shift your “normal” values over by one. If you put an asterisk in the first position, it gets evaluated by the Like operator as a wildcard, and the criteria returns any value for that field when the index value is zero + 1. Putting an asterisk at the last position in the list allows you to handle an index that is outside the values you want to specify. That one will just return all the possible values for that field the same as the zero does.
-
-
-
-
Viewing 0 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Discover the Best AI Tools for Everything
by
Alex5723
4 hours, 44 minutes ago -
Edge Seems To Be Gaining Weight
by
bbearren
5 minutes ago -
Rufus is available from the MSFT Store
by
PL1
15 hours, 43 minutes ago -
Microsoft : Ending USB-C® Port Confusion
by
Alex5723
17 hours, 52 minutes ago -
KB5061768 update for Intel vPro processor
by
drmark
17 minutes ago -
Outlook 365 classic has exhausted all shared resources
by
drmark
16 hours, 3 minutes ago -
My Simple Word 2010 Macro Is Not Working
by
mbennett555
13 hours, 37 minutes ago -
Office gets current release
by
Susan Bradley
16 hours, 15 minutes ago -
FBI: Still Using One of These Old Routers? It’s Vulnerable to Hackers
by
Alex5723
2 days, 6 hours ago -
Windows AI Local Only no NPU required!
by
RetiredGeek
1 day, 14 hours ago -
Stop the OneDrive defaults
by
CWBillow
2 days, 7 hours ago -
Windows 11 Insider Preview build 27868 released to Canary
by
joep517
2 days, 17 hours ago -
X Suspends Encrypted DMs
by
Alex5723
2 days, 19 hours ago -
WSJ : My Robot and Me AI generated movie
by
Alex5723
2 days, 19 hours ago -
Botnet hacks 9,000+ ASUS routers to add persistent SSH backdoor
by
Alex5723
2 days, 20 hours ago -
OpenAI model sabotages shutdown code
by
Cybertooth
2 days, 20 hours ago -
Backup and access old e-mails after company e-mail address is terminated
by
M W Leijendekker
2 days, 8 hours ago -
Enabling Secureboot
by
ITguy
2 days, 15 hours ago -
Windows hosting exposes additional bugs
by
Susan Bradley
3 days, 4 hours ago -
No more rounded corners??
by
CWBillow
3 days ago -
Android 15 and IPV6
by
Win7and10
2 days, 14 hours ago -
KB5058405 might fail to install with recovery error 0xc0000098 in ACPI.sys
by
Susan Bradley
3 days, 17 hours ago -
T-Mobile’s T-Life App has a “Screen Recording Tool” Turned on
by
Alex5723
3 days, 19 hours ago -
Windows 11 Insider Preview Build 26100.4202 (24H2) released to Release Preview
by
joep517
3 days, 14 hours ago -
Windows Update orchestration platform to update all software
by
Alex5723
4 days, 3 hours ago -
May preview updates
by
Susan Bradley
3 days, 14 hours ago -
Microsoft releases KB5061977 Windows 11 24H2, Server 2025 emergency out of band
by
Alex5723
3 days, 6 hours ago -
Just got this pop-up page while browsing
by
Alex5723
3 days, 19 hours ago -
KB5058379 / KB 5061768 Failures
by
crown
3 days, 16 hours ago -
Windows 10 23H2 Good to Update to ?
by
jkitc
2 days, 18 hours ago
Recent blog posts
Key Links
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.