Help on command bar
I
![]() |
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 |
-
Help on command bar (97)
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Help on command bar (97)
- This topic has 4 replies, 2 voices, and was last updated 22 years, 9 months ago.
AuthorTopicViewing 0 reply threadsAuthorReplies-
WScharlotte
AskWoody LoungerSeptember 5, 2002 at 3:16 am #614225I’m not quite sure what you’re trying to do here, nor why you’re deleting and recreating a toolbar, but the expression you’re trying to evaluate in your Select Case returns a pointer to the Controls collection for that menubar. A select case should return a result that you can compare to each of its cases. You can’t compare a collection to whether some member of it is null, which is what you’re trying to do. In this instance, a Select Case isn’t the appropriate structure for your code. Try this instead (and note that the references to the combobox controls inside the With-End With have a dot in front of them:
Dim cbr As CommandBar Set cbr = CommandBars("Filter Menu") With cbr If Not IsNull(.Controls("RegionCombo")) And Not IsNull(.Controls("ManagerCombo")) Then MsgBox "Provide only one value, REGION or MANAGER, not both.", vbOKOnly DoCmd.RunMacro "mcrDeleteToolbar" DoCmd.RunMacro "mcrCreateToolbar" ElseIf IsNull(.Controls("RegionCombo")) Then strFilter = "qryDtlMgrMth6.DirectorCode =" _ & Choose(.Controls("regionCombo").Index, 1500, 1300, 1400, 1100, 1200) _ & " AND qryDtlMgrMth6.Year =" & filterYear _ & " AND qryDtlMgrMth6.promotionType='" & filterType & "'" ElseIf IsNull(.ManagerCombo) Then strFilter = "qryDtlMgrMth6.Code =" _ & Choose(.Controls("managerCombo").Index, 1500, 1300, 1400, 1100, 1200) _ & " AND qryDtlMgrMth6.Year =" & filterYear _ & " AND qryDtlMgrMth6.promotionType='" & filterType & "'" End If End With Set cbr = Nothing
I’m assuming here that regioncombo and managercombo are the names of the two comboboxes on your “filter menu” commandbar. If that isn’t valid, you’ll have to play with the code. Even if the code compiles, I think you’ll have problems, though, because you’re first testing to see if a combo is null and then, if it is, you’re trying to use its index to choose a value. Wouldn’t you want to do it the other way around? By that I mean, if the RegionCombo is null, use the ManagerCombo information and vice versa?
-
WSarage
AskWoody Lounger -
WSarage
AskWoody Lounger -
WScharlotte
AskWoody LoungerSeptember 6, 2002 at 3:40 am #614542It was air code and only intended to get you started in another direction. Try taking out the with-end with and using the full reference for the controls. Depending on how your commandbar is set up, you may have to modify the references. Here’s a sample of a routine that takes action based on a combobox value, but it uses the ListIndex property, not the Index property of a commandbar combobox. BTW, the code is fornatted using Pre tags from the tag panel. For that reason, if you copy formatted code like this, paste it into Word first. Then copy it from there and paste it into your module.
Public Function cbEvalCombo(ByVal strMenuName As String, _ ByVal strCBOName As String) Dim cbo As CommandBarComboBox Dim cbr As CommandBar Set cbr = CommandBars(strMenuName) Set cbo = cbr.Controls(strCBOName) Select Case cbo.ListIndex Case 1 MsgBox "First item selected" Case 2 MsgBox "Second item selected" End Select Set cbo = Nothing Set cbr = Nothing End Function
It seems to me the easiest way to handle your problem would be to make the first item in your list an empty string. Then they could always select that to clear the value or you could set ListIndex to 1 to clear it and you wouldn’t have to delete and recreate the commandbar.
-
-
-
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
-
Firefox 139
by
Charlie
2 hours, 11 minutes ago -
Who knows what?
by
Will Fastie
5 minutes ago -
My top ten underappreciated features in Office
by
Peter Deegan
52 minutes ago -
WAU Manager — It’s your computer, you are in charge!
by
Deanna McElveen
9 hours, 7 minutes ago -
Misbehaving devices
by
Susan Bradley
1 hour, 52 minutes ago -
.NET 8.0 Desktop Runtime (v8.0.16) – Windows x86 Installer
by
WSmeyerbos
1 day, 2 hours ago -
Neowin poll : What do you plan to do on Windows 10 EOS
by
Alex5723
3 minutes ago -
May 31, 2025—KB5062170 (OS Builds 22621.5415 and 22631.5415 Out-of-band
by
Alex5723
1 day, 1 hour ago -
Discover the Best AI Tools for Everything
by
Alex5723
33 minutes ago -
Edge Seems To Be Gaining Weight
by
bbearren
15 hours, 38 minutes ago -
Rufus is available from the MSFT Store
by
PL1
23 hours, 40 minutes ago -
Microsoft : Ending USB-C® Port Confusion
by
Alex5723
2 days, 2 hours ago -
KB5061768 update for Intel vPro processor
by
drmark
2 hours, 20 minutes ago -
Outlook 365 classic has exhausted all shared resources
by
drmark
1 hour, 3 minutes ago -
My Simple Word 2010 Macro Is Not Working
by
mbennett555
1 day, 22 hours ago -
Office gets current release
by
Susan Bradley
2 days ago -
FBI: Still Using One of These Old Routers? It’s Vulnerable to Hackers
by
Alex5723
3 days, 14 hours ago -
Windows AI Local Only no NPU required!
by
RetiredGeek
2 days, 23 hours ago -
Stop the OneDrive defaults
by
CWBillow
3 days, 15 hours ago -
Windows 11 Insider Preview build 27868 released to Canary
by
joep517
4 days, 1 hour ago -
X Suspends Encrypted DMs
by
Alex5723
4 days, 3 hours ago -
WSJ : My Robot and Me AI generated movie
by
Alex5723
4 days, 4 hours ago -
Botnet hacks 9,000+ ASUS routers to add persistent SSH backdoor
by
Alex5723
4 days, 4 hours ago -
OpenAI model sabotages shutdown code
by
Cybertooth
4 days, 5 hours ago -
Backup and access old e-mails after company e-mail address is terminated
by
M W Leijendekker
3 days, 17 hours ago -
Enabling Secureboot
by
ITguy
4 days ago -
Windows hosting exposes additional bugs
by
Susan Bradley
4 days, 13 hours ago -
No more rounded corners??
by
CWBillow
4 days, 9 hours ago -
Android 15 and IPV6
by
Win7and10
3 days, 22 hours ago -
KB5058405 might fail to install with recovery error 0xc0000098 in ACPI.sys
by
Susan Bradley
5 days, 1 hour 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.