toolbars (1 Viewer)

lscheer

Registered User.
Local time
Today, 21:53
Joined
Jan 20, 2000
Messages
185
I know I posted this recently, but I got no response. I'm trying to figure it out still, especially for queries.

My DB has TONS of queries, so it would be best if I could assign this as a default for all queries if possible. Any help would be great.

Is it possible to assign, for instance, my custom queries toolbar to be shown whenever queries are opened (in either datasheet or design view) and hidden when queries are not open (similar to the built-in toolbars, but I don't want to use the built-in toolbars)?

OR is it possible to just use the built-in queries toolbar, but deactivate all the other built-in toolbars?
 

Alexandre

Registered User.
Local time
Tomorrow, 03:53
Joined
Feb 22, 2001
Messages
794
Both solutions are possible (replace default toolbars from the start, or change them 'on the fly'). Below is a code snippet adapted from a function I hade written to manage custom toolbars with reports and queries. I had to make some changes to simplify it, so I could not test the result. But it should work, or at least show you the logics.

Code:
Dim msg As String, strActiveMenu As String
Dim strMenuBar As String

strMenuBar = 'The name of your custom Toolbar

DoCmd.Echo False
DoCmd.Hourglass True
    
'Hide MenuBars (assume hat the query is opened from a form
'we save the name of the current toolbar in a variable. You could skip that
'if you always know what is the current toolbar before opening your query and changing the toolbar
strActiveMenu = Screen.ActiveForm.Name
strActiveMenu = Forms.Item(strActiveMenu).MenuBar

'We call a macro hiding all the default toolbars (it uses
'ShowHideToolbar for each default toolbar : Database, form view, form design...
DoCmd.RunMacro HideToolbars        

'Open the query
DoCmd.OpenQuery "HereGoesyourQueryName", acViewNormal, acReadOnly

'Set the custom MenuBar
Application.MenuBar = strMenuBar


'Show the Query with the Custom MenuBar where appropriate
DoCmd.Echo True
DoCmd.Hourglass False
DoCmd.ShowToolbar strMenuBar, acToolbarWhereApprop         
                
'While the query is opened..wait
While SysCmd(acSysCmdGetObjectState, acQuery, "HereGoesYourQueryName")
    DoEvents
Wend
                
                
'Hide Custom Object MenuBar
DoCmd.ShowToolbar strMenuBar, acToolbarNo
        

'Restore Form View Custom MenuBar
Application.MenuBar = strMenuBar 
DoCmd.ShowToolbar strMenuBar , acToolbarYes

Hope this helps
 
Last edited:

tanalee

Registered User.
Local time
Today, 21:53
Joined
Apr 25, 2002
Messages
10
Aloha...

I'm not a programmer, but there seems to be a lot of information under Access Help 'Menus, creating' and 'Toolbars, customizing'.

Have youi checked it out?

Tana
 

lscheer

Registered User.
Local time
Today, 21:53
Joined
Jan 20, 2000
Messages
185
Thanks, Alexandre

I was able to simplify it even more and it's working! Thanks again. :)


BTW Tana, Yes, I have searched High and Low in MSAccess Help, and the help just isnt there for this kind of thing. It goes beyond simply customizing toolbars. Thanks, though.
 

Users who are viewing this thread

Top Bottom