Smart questions
Smart answers
Smart people
Join Tek-Tips Forums
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

blackduck (Programmer) (OP)
9 Sep 08 19:14
Is there a way, using code, to show the menus.

I have my own login security setup and have used the Tools>Startup> uncheck allow menus to hide the database window and other menus. (ps. I know shift bypass kills all of this - damn!).

I have two buttons with the code below to show/hide the database window and that part works fine.
'To show the database window
    DoCmd.SelectObject acTable, , True

'To Hide the database window
    DoCmd.SelectObject acTable, , True
    DoCmd.RunCommand acCmdWindowHide

I just want to add some more code to be able to show and hide the menus as well.
Remou (TechnicalUser)
10 Sep 08 4:06
Yes, you can. You can also suppress the shift key (http://www.mvps.org/access/general/gen0040.htm)

PropName=AllowFullMenus

CODE

Public Sub SetProp(PropName As String, PropVal As Variant, Optional PropType = dbText)
     Dim db As Object
     Dim prp As Object
     Dim strTitle As String
   
     Const PROPERTY_NOT_FOUND As Integer = 3270
   
     On Error GoTo ErrorHandler
   
     Set db = CurrentDb
   
     ' Try to set the property. If it fails, the property does not exist.
     db.Properties(PropName) = PropVal
   
  ExitLine:
     db.Close
     Set db = Nothing
     Set prp = Nothing
     Exit Sub
   
  ErrorHandler:
     If Err.Number = PROPERTY_NOT_FOUND Then
        ' Create the new property.
        Set prp = db.CreateProperty(PropName, PropType, PropVal)
        db.Properties.Append prp
        Resume Next
     Else
        Resume ExitLine
     End If
   
  End Sub

From: http://wiki.lessthandot.com/index.php/Setting_Start-Up_Options_Using_VBA
blackduck (Programmer) (OP)
21 Sep 08 10:58
Thanks Remou, sorry for late reply. I read your reply and the links but I think this goes a bit beyond my vba skills/understanding.

I went back to using the Tools>startup options and unchecked all the boxes. This worked fine because it still left a small menu, eg the user could still see file, print.

I still want to be able to use code to show the database window, and full menu (ie the one that has file>get external data). Using a button I have setup which is only visible to certain users.

The code I put in the button onclick event is as follows, but it doesnt put back the full menu or toolbars it just seems to ignore it (I copied the code from somewhere)

'Unhide the database window (this works)
   DoCmd.SelectObject acTable,,True
'Unhide menu bar (doesnt work)
   DoCmd.ShowToolbar "Menu Bar", acToolbarYes
'also tried (doesnt work)
   CommandBars.activeMenuBar.Enabled = true
 
Helpful Member!  TheAceMan1 (Programmer)
21 Sep 08 18:03
How are ya blackduck . . .

Example:

CODE

   CommandBars("MenuName or ToolbarName").Enabled = False

Your Thoughts? . . .

See Ya! .  .  .  .  .  .

Be sure to see thread181-473997: How To Get Good Answers To Your Questions  Worthy Reading! thumbsup2
Also FAQ181-2886: How can I maximize my chances of getting an answer?  Worthy Reading! thumbsup2
                 

SeeThru (IS/IT--Management)
22 Sep 08 12:18
Hi Remou

I current have the default toolbars disabled - will you function allow me to re-enable them for full edit mode?

At the moment I have to close the database and re-open wit hthe bypass key, but that would be a neater way to do it.

SeeThru  
Synergy Connections Ltd - Telemarketing Services

 

blackduck (Programmer) (OP)
22 Sep 08 19:06
Thanks AceMan
It didn't quite work. It may have something to do with me unchecking all the boxes via the tools>startup options.

If I go in via the shift bypass method, I can use your code to hide the full menu bar, then I can use your code to show the full menu bar. I made two buttons CommandBars("Menu Bar").Enabled=True and another =False

This could actually be a better solution. But then I like using the tools>startup uncheck because it leaves just a short menu which allows users to have the print and print preview which is needed for reports.

Id like to use your code, not the startup options, but any idea how I can make just that short default menu stay?
  
TheAceMan1 (Programmer)
22 Sep 08 21:10
blackduck . . .

Your easiest solution (no code required) would be to design your own Custom Menu Bar for this. Then in StartUp Options select the custom bar name and your done. When you open the form its the custom bar thats displayed!

Your Thoughts? . . .

See Ya! .  .  .  .  .  .

Be sure to see thread181-473997: How To Get Good Answers To Your Questions  Worthy Reading! thumbsup2
Also FAQ181-2886: How can I maximize my chances of getting an answer?  Worthy Reading! thumbsup2
                 

blackduck (Programmer) (OP)
23 Sep 08 2:14
Yip Yah!  Big hug to TheAceMan1.

Here is what I have done:

Created custom menu bar (with just page setup, print preview, print).
Startup options:
- Menu Bar =(default) DO NOT change this to your new one. It has to load first otherwise you cant get it to show again using code.
- checked Allow full menus, allow shortcut menu.
- unchecked everything else.
- Display form/page = eg.frmMainMenu

In the onOpen event of my form eg.frmMainMenu, code:
'Hide the default menu bar
    CommandBars("menu bar").Enabled = False

Therefore, when the db is open, my form appears, my custom menu bar is there and nothing else (looks great!)

I created another form only visible to certain users, and coded two buttons as follows:
Private Sub cmdShow_Click()
'Show the database window
    DoCmd.SelectObject acTable, , True
'Show full menu bar
    CommandBars("menu bar").Enabled = True
End Sub

Private Sub cmdHide_Click()
'Hide the database window
    DoCmd.SelectObject acTable, , True
    DoCmd.RunCommand acCmdWindowHide
'Hide full menu bar
    CommandBars("menu bar").Enabled = False
End Sub

Now my usual users have access to print options but nothing else. My power users have complete access to the database and can import external data etc which is what I wanted.

what a relief
thanks heaps to everyone (especially TheAceMan1 who kept me thinking outside the square)

 
1VBAnewbie (TechnicalUser)
13 Oct 08 3:38
blackduck,

your solution is exactly what I am attempting. Using Access 2003 and its so-called Help, I have not been able to find how to create a customer menu bar. I can create a custom toolbar and custom menu on the standard/default menu bar.

I know in situations such as this, there is always a quick solution that normally is under my nose. Would you please point my nose in the right direction as to how a custom menu bar may be created?

Thanks in advance for your courtesy.
1VBAnewbie (TechnicalUser)
13 Oct 08 3:57
OK; so I just needed to look a little further. Another thread provided the clue I needed. I'm on my way. Sorry you needed to read through this unneeded post.
blackduck (Programmer) (OP)
13 Oct 08 7:14
Glad you found it. For the record I used a nice little tutorial I had found from http://www.jamiessoftware.tk/articles/menubars.html. But I'm sure the tek-tips team would have already covered it nicely.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close