Toolbar item disable

Bechert

Registered User.
Local time
Today, 15:00
Joined
Apr 11, 2003
Messages
59
Hi, I have created a custom menu bar for my application at design-time. At runtime I successfully disable controls and sub-menu items on the menu bar based on what the user can do on a particulare form or report. The following code works for menu bar items and sub-menus:
CommandBars("PT DocToolMenuBar").Controls("Print").CommandBar.Controls("Close").Enabled = True

I have also created a toolbar (short-cut), the name is "ToolBar - Appointments", at design time. The user accesses the toolbar with a right-click on a specific form. I want to disable items on the toolbar based on what the user is attempting to do. I have the following coded in a MouseDown event:
CommandBars("ToolBar - Appointments").Controls("Block Time").Enabled = False
I receive the following runtime error "Invalid Procedure call or Argument", err.number = 5.

Can anyone tell me what I am doing wrong?

Thanks,
Bill
 
My initial thought is that hyphen you have there in the toolbar name. Never ever use any characters outside of the alpha-numeric and underscore when naming things in any program or programming language. Sometimes the program will try to evaluate it. So it may think you're looking for:

Toolbars (Minus) Appointments
 
Thanks for the reply Pdx_Man. I tried your suggestion - removing the special character ( "-") and spaces.
The new code is CommandBars("ToolBarAppointments").Controls("Block Time").Enabled = False

but I receive the same runtime error - "Invalid Procedure call or Argument". I did update the form properties to refer to the new toolbar name (ToolBarAppointments).

Is there something unique about how short-cut toolbars are referenced?

Any other ideas?

Thanks for your help,
Bill
 
... and you have a Referrence to the Microsoft Office 9.0 Object Library ... and the toolbar item within the ToolBarAppointments name is Block Time with the space in it?

If this is all true, then my last suggestion would be to rename the item without the space.

This is something that has worked for me exactly as you have it defined, but I don't have spaces in my item names.
 
Were you able to disable the items on the toolbar?
I have a similar situation and I want to disble the 'Delete' button on the standard toolbar. I am sure this is possible but I am not sure of how to do it using code when the form loads.
Any help will be appreciated.
:p
 
You would be better off creating a custom toolbar that only displays the commands that you want the user to use for the standard tool bars give them too much access to your db. You can easily disable the delete record option in a form but using this command...

Code:
Me.AllowDeletions = False
 

Users who are viewing this thread

Back
Top Bottom