Help on command bar
I
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
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, 8 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
-
Windows 11 Insider Preview Build 26100.4188 (24H2) released to Release Preview
by
joep517
3 hours, 44 minutes ago -
Microsoft is now putting quantum encryption in Windows builds
by
Alex5723
1 hour, 43 minutes ago -
Auto Time Zone Adjustment
by
wadeer
8 hours, 14 minutes ago -
To download Win 11 Pro 23H2 ISO.
by
Eddieloh
5 hours, 54 minutes ago -
Manage your browsing experience with Edge
by
Mary Branscombe
1 hour, 16 minutes ago -
Fewer vulnerabilities, larger updates
by
Susan Bradley
8 minutes ago -
Hobbies — There’s free software for that!
by
Deanna McElveen
1 hour, 42 minutes ago -
Apps included with macOS
by
Will Fastie
1 hour, 20 minutes ago -
Xfinity home internet
by
MrJimPhelps
1 hour, 15 minutes ago -
Convert PowerPoint presentation to Impress
by
RetiredGeek
1 hour, 13 minutes ago -
Debian 12.11 released
by
Alex5723
1 day, 5 hours ago -
Microsoft: Troubleshoot problems updating Windows
by
Alex5723
1 day, 9 hours ago -
Woman Files for Divorce After ChatGPT “Reads” Husband’s Coffee Cup
by
Alex5723
12 hours, 30 minutes ago -
Moving fwd, Win 11 Pro,, which is best? Lenovo refurb
by
Deo
4 hours, 54 minutes ago -
DBOS Advanced Network Analysis
by
Kathy Stevens
2 days, 1 hour ago -
Microsoft Edge Launching Automatically?
by
healeyinpa
1 day, 16 hours ago -
Google Chrome to block admin-level browser launches for better security
by
Alex5723
2 days, 4 hours ago -
iPhone SE2 Stolen Device Protection
by
Rick Corbett
1 day, 20 hours ago -
Some advice for managing my wireless internet gateway
by
LHiggins
1 day, 4 hours ago -
NO POWER IN KEYBOARD OR MOUSE
by
HE48AEEXX77WEN4Edbtm
6 hours, 25 minutes ago -
A CVE-MITRE-CISA-CNA Extravaganza
by
Nibbled To Death By Ducks
2 days, 14 hours ago -
Sometimes I wonder about these bots
by
Susan Bradley
2 hours, 14 minutes ago -
Does windows update component store “self heal”?
by
Mike Cross
2 days ago -
Windows 11 Insider Preview build 27858 released to Canary
by
joep517
3 days, 4 hours ago -
Pwn2Own Berlin 2025: Day One Results
by
Alex5723
1 day, 12 hours ago -
Windows 10 might repeatedly display the BitLocker recovery screen at startup
by
Susan Bradley
1 day ago -
Windows 11 Insider Preview Build 22631.5409 (23H2) released to Release Preview
by
joep517
3 days, 6 hours ago -
Windows 10 Build 19045.5912 (22H2) to Release Preview Channel
by
joep517
3 days, 6 hours ago -
Kevin Beaumont on Microsoft Recall
by
Susan Bradley
1 hour, 27 minutes ago -
The Surface Laptop Studio 2 is no longer being manufactured
by
Alex5723
3 days, 14 hours ago
Recent blog posts
Key Links
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.