By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,053 Members | 1,595 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,053 IT Pros & Developers. It's quick & easy.

custom command bars

P: n/a
I am trying to create a custom command bar with three custom buttons,
however when I try to make the procedure there is no "CommandBar"
option to choose from and is not recognized for the following...

Dim NtsT1 As CommandBar
Dim NtsT1Btn1 As CommandBarButton
Dim NtsT1Btn2 As CommandBarButton
Dim NtsT1Btn3 As CommandBarButton

There is a CommandBarEvents and 2 CommandBarButton to select but no
CommandBar to select. Please excuse my stupidity if this is a dumb
question as I am not well versed in Access and VBA programming but in
the "Programming Microsoft Access Version 2002" book by Rick Dobson it
shows I should be able to create a custom command bar with custom
buttons. If any one knows what i am doing wrong or has another option
for me to try. (I need a pop up message box which gives 3 options to
pick from which then performs a function based on the user's choice.
the pop up would be activated by a existing command bar on a form)

Thank You
Shane
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
First, make sure you have a reference to the Microsoft Object Library
for 2002. Here is some commandbar code (Access97)

Sub cmdBarStuff()
Dim CB As CommandBar, ctl As CommandBarControl
Set CB = CommandBars("newTest1")
For Each ctl In CB.Controls
Debug.Print ctl.Caption
Debug.Print ctl.DescriptionText
Debug.Print ctl.OnAction
Debug.Print ctl.HelpContextId
Debug.Print ctl.HelpFile
Debug.Print ctl.Id
Debug.Print ctl.Index
Next
End Sub

For my OnAction, I created a simple function in a standard module.

Function TestMsg()
msgBox "testing from TestMsg()"
End Function

You can create your custom commandbar either in code or by
right-clicking on a toolbar and choose customize, then in the Toolbars
tab, select New and name it. For a control, you can drag a control from
the list of controls in the "Commands" tab of the customize dialogbox.
The first option in the list is "File". Scroll down on the right side
and select "Run Macro". That is a straight forward button. Then click
on the control on the new toolbar to enable the "Modify Selection"
button on the dialogbox if it isn't already enabled.. Now go back to
the dialogbox and click on the Modify Selection button. Click on
Properties on the Menu that comes up. In the On Action field - type in
your function like this:

=TestMsg()

Note: you need to include the = symbo and the parentheses.

Close up the dialogbox and click on your new custom button on the custom
toolbar. A message box will appear.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #2

P: n/a

"First, make sure you have a reference to the Microsoft Object Library
for 2002."

I have the following referenced...
"microsoft forms 2.0 object library"
"microsoft access 11.0 object library"

Are either of those the ones I need or is there one I am missing?

Thanks for the posting

Shane
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3

P: n/a
I believe you need to make a reference to

Microsoft Office 10.0 object Library

(or Microsoft Office 11.0 object library). I think 10.0 is the one for
office xp. I have it at home, but not handy right now. 2002 should be
xp, .. 10.0

Then you can

Dim CB As CommandBar

Commandbars are part of the Microsoft Office Object library. Without a
reference to the correct libary you can't declare commandbars.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.