Custom Menus almost working

G

Guest

I have 2 routines that almost produce the results I want.

1) EnableDefaultMenu () ---just resets everything
2) InvokeUserMenu () ---almost works - but probably serendipitously


I have a startup routine that checks users and sets their menu, because the
"ChangeProperty" routine I tried will only work after the NEXT time the
database is open. The above routines happen immediately.

The InvokeUserMenu effectively removes the other menus I dont' want them to
see, so I probably don't need the inner loop. (It doesn't even touch it)

It boils down to - It sure would be nice if whenever a report is open the
only button a user sees is the "CLOSE" button - the one that closes the
report (not exit, or any other button or menu)

If anyone has CommandBar down to a science, please help me figure out how to
adjust this code to get the results I want?

'Code provided below
'====================================================

Public Sub EnableDefaultMenu()
On Error Resume Next
Dim obar As CommandBar

For Each obar In Application.CommandBars
obar.Reset
Next
End Sub


Public Sub InvokeUserMenu()
Dim cbarMenu As CommandBar
Dim cbarControl As CommandBarControl
Dim strBar As String
Dim strList As String

On Error Resume Next
For Each cbarMenu In Application.CommandBars

For Each cbarControl In cbarMenu.Controls 'command bars
If cbarControl.Caption = "&File" Or cbarControl.Caption = "&Edit"
Or cbarControl.Caption = "&Window" Then 'parent menus
'MsgBox "Parent Menu: " & cbarControl.Caption
MsgBox "Will Keep this menu: " & cbarControl.Caption
'====================== 'menu items
If cbarControl.Type = msoBarTypeMenuBar Then
'If cbarControl.Enabled = True Then

' MsgBox "menu item: " & cbarControl.Caption
If cbarControl.Caption = "&Close" Or _
cbarControl.Caption = "&Print" Or _
cbarControl.Caption = "&Find..." Or _
cbarControl.Caption = "R&eplace..." Or _
cbarControl.Caption = "Ti&le Horizontally" Or _
cbarControl.Caption = "&Tile Vertically" Or _
cbarControl.Caption = "&Cascade" Or _
cbarControl.Caption = "Microsoft Access &Help"
Then

'any item from the above list should be enabled
MsgBox "Will keep this menu item: " &
cbarControl.Caption

Else ' not a chosen menu item
cbarControl.Visible = False
End If
'End If 'item was enabled
End If 'checking if it is a menuitem


'=====================
Else 'if not one of the chosen menus... disable it

cbarControl.Visible = False
End If
Next

Next

Set cbarMenu = Nothing
End Sub
 
P

PC Datasheet

You're doing it the HARD way!!

Just create a custom menu with only a Close button. Make sure the custom
menu is a menubar. Open the report, go to properties and the Other tab, set
the Default Menu property to the name of the custom menu you just created.
When you open the report, the custom menu will appear at the top of the
screen. You can also do this with forms.
 
G

Guest

Ok, I created my custom bar called "ReportView" - it only has a close button
on it
But the Menu Bar is still there - I don't want to show the menu bar.

Also, what do you mean by "Default Menu" property?

The 'other' tab only has:

Menu Bar
Toolbar
Shortcut Menu Bar






I didn't see anything about 'Default Menu'
 
P

PC Datasheet

Create a custom menu bar for your application that only has buttons that
provide the functionality you want throughout your database. Go to
Tools-Startup and on the bottom right of the dialog set the application
menubar to your new menubar. Your new menubar will appear at the top of the
screen in place of the Access menubar.

Sorry!
"Default Menu" = Menubar

Now that you have a custom application menubar, when you open the report,
your report menubar will replace the custom application menubar and all you
will have is the Close button.
 
G

Guest

Ok. I DO want to master this, because, if I don't have to write code that
would be better. However, nothing you have prescribed is working yet.

1) I created a custom menu bar called "CIMenu"
But when I go to "Tools-Startup - at the bottom right of the dialog set"
I don't see anything in the dropdown, so I manually type in CIMenu

(Although, I distinctly remember at times seeing a custom menu listed there-
this time there is nothing)

I first get an error that I'm using the wrong menu type for the startup -
and of course, I don't get the menu in place of the regular menu bar.

What should I do to make sure everything is in place?
What if I dont' want ANY menu, except for the Print Preview menu when
reports show, I dont' really need to make a new menu if I can just get the
Print Preview menu to be the only menu that ever shows.
 

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

Similar Threads


Top