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
-
Ascension says recent data breach affects over 430,000 patients
by
Nibbled To Death By Ducks
1 hour, 14 minutes ago -
Nintendo Switch 2 has a remote killing switch
by
Alex5723
1 hour, 34 minutes ago -
Blocking Search (on task bar) from going to web
by
HenryW
6 hours, 15 minutes ago -
Windows 10: Microsoft 365 Apps will be supported up to Oct. 10 2028
by
Alex5723
11 hours, 22 minutes ago -
Add or Remove “Ask Copilot” Context Menu in Windows 11 and 10
by
Alex5723
11 hours, 29 minutes ago -
regarding april update and may update
by
heybengbeng
12 hours, 58 minutes ago -
MS Passkey
by
pmruzicka
46 minutes ago -
Can’t make Opera my default browser
by
bmeacham
20 hours, 38 minutes ago -
*Some settings are managed by your organization
by
rlowe44
7 hours, 21 minutes ago -
Formatting of “Forward”ed e-mails
by
Scott Mills
19 hours, 33 minutes ago -
SmartSwitch PC Updates will only be supported through the MS Store Going Forward
by
PL1
1 day, 15 hours ago -
CISA warns of hackers targeting critical oil infrastructure
by
Nibbled To Death By Ducks
2 days ago -
AI slop
by
Susan Bradley
14 hours, 20 minutes ago -
Chrome : Using AI with Enhanced Protection mode
by
Alex5723
2 days, 1 hour ago -
Two blank icons
by
CR2
13 hours, 15 minutes ago -
Documents, Pictures, Desktop on OneDrive in Windows 11
by
ThePhoenix
2 days, 10 hours ago -
End of 10
by
Alex5723
2 days, 13 hours ago -
Single account cannot access printer’s automatic duplex functionality
by
Bruce
1 day, 11 hours ago -
test post
by
gtd12345
2 days, 19 hours ago -
Privacy and the Real ID
by
Susan Bradley
2 days, 9 hours ago -
MS-DEFCON 2: Deferring that upgrade
by
Susan Bradley
11 hours, 35 minutes ago -
Cant log on to oldergeeks.Com
by
WSJonharnew
2 days, 23 hours ago -
Upgrading from Win 10
by
WSjcgc50
1 day, 11 hours ago -
USB webcam / microphone missing after KB5050009 update
by
WSlloydkuhnle
1 day, 14 hours ago -
TeleMessage, a modified Signal clone used by US government has been hacked
by
Alex5723
3 days, 15 hours ago -
The story of Windows Longhorn
by
Cybertooth
3 days, 2 hours ago -
Red x next to folder on OneDrive iPadOS
by
dmt_3904
3 days, 17 hours ago -
Are manuals extinct?
by
Susan Bradley
17 hours, 27 minutes ago -
Canonical ditching Sudo for Rust Sudo -rs starting with Ubuntu
by
Alex5723
4 days, 2 hours ago -
Network Issue
by
Casey H
3 days, 13 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.