Menubar

  • Thread starter Thread starter Harmannus
  • Start date Start date
H

Harmannus

Hallo,

Is it possible to put the below code on a menubar (showing the actual
application title that is set in the startup screen) through te customize
button? If yes how do i do this. Tried various menubar fields but no effect.

"[" & CurrentDb.Properties("AppTitle") & "]"

Thanx for any tips!

Regards,

Harmannus
 
I don't think so...since the caption name becomes the actual name used for
the control in the collection..and that can't be resolved at runtime.

You can certainly "set" the caption via code..but be very careful..since
changing the name of the caption also changes the name of the control.

I would NOT change captions at runtime..since that means your menu bar order
likely will change it order. However, if you ALWAYS ref the menu options via
the collection name and NOT the index position....then you should be ok. I
always used the full name of the contorl so if you modify the menu or add
new items..then the code will still work.

For example:

MsgBox CommandBars("test2").Controls("kkkk").Caption

' now, lets change the caption of contorl "kkkk" to the currenet database
CommandBars("test2").Controls("kkkk").Caption = CurrentDb.Name

MsgBox CommandBars("test2").Controls("kkkk").Caption

The ABOVE LINE WILL FAIL! since now the caption name is c:\my
docuemnts\test1.mdb
We would have to go:

MsgBox CommandBars("test2").Controls("c:\my docuemnts\test1.mdb).Caption


If you are going to change caption names at runtime..then I suggest you
create the menu in code..and not use the UI to make those menus...(since
changing captions will change the original value in the controls
"collection". So, don't change the name..but simply "add" this control with
the caption you want.

There is some code samples are making the menus from scratch in code here:

http://www.microsoft.com/Accessdev/articles/bapp97/chapters/ba01_6.htm
 
Hallo Albert,

Thanx again for you usefull help ;-)

I will give it a try!

Regards,
Harmannus
 
Back
Top