Custom Commandbar issue

D

Dale Fye

I've got a custom command bar (MyFileMenu), which contains Close and Quit
options. On my Splash form, I want the Close option to only be visible if
I'm in debugging mode (I've got a function to determine if this is true or
false). So in the forms Activate event, I have the following code:

Private Sub Form_Activate()

Dim cbr as object

set cbr = Application.CommandBars("MyFileMenu")
cbr.FindControl(Tag:="MyFileQuit").Visible = True
cbr.FindControl(Tag:="MyFileClose").Visible = fnDebugging

End Sub

Then, when the user leaves the Splash screen, I want to hide the Quit option
and unhide the Close option. The following code works to accomplish this.

Private Sub Form_Deactivate()

Dim cbr as object

set cbr = Application.CommandBars("MyFileMenu")
cbr.FindControl(Tag:="MyFileQuit").Visible = False
cbr.FindControl(Tag:="MyFileClose").Visible = True

End Sub

The problem is that when the Splash screen opens, it displays both options,
even if I'm not in debugging mode. When I open another form (the splash
screen gets hidden when this happens) the Deactivate code fires and the Close
option becomes visible and the Quit option gets hidden. When I close the
second form, the Splash screens Activate code fires again, and now the Close
option visibility works based on fnDebugging( ).

I'm going batty with this, so I would appreciate any suggestions.

--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.
 
G

George Nicholson

Sounds like a timing issue. When you you set fnDebugging to True? I bet its
after the Spalsh first activates.
One approach: repeat the appropriate line once you have set fnDebugging to
True.
 
D

Dale Fye

Actually, George.

fnDebugging is a function that checks the status of a field in my
db_parameters table, so the value of the function is always the value of the
field in the table.

The sequence of events for this thing is:

Form_Open. during this process, I create the custom menubars (I'll take a
look at setting the visible property of the Close option to false on
creation, that might work).

Form_Activate. runs the code. I put a debug line in the activate line to
see what the value of fnDebugging is, and it set to False, but the option is
still visible on initial load.

Form_Deactivate

I'll post back after I have tested setting the visible property to false
when the menu is created.

Dale
--


email address is invalid
Please reply to newsgroup only.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top