Solved

Menu Bar doesn't stay disabled

Posted on 1998-09-25
4
210 Views
Last Modified: 2008-03-03
Greetings, reader of this question,

I use Access8 (1997) to set up a small registration system. To avoid users to ravage my application, I created my own toolbars and disabled the build in commandbar called "Menu Bar". This "Menu Bar" isn't a menubar at all, it's a toolbar.
Now, to disable this menubar I used the "Start up" function in the "Extra" menu (I hope your local versions use these menu and function names), but also included in th starting up forms this code:

Application.Commandbars("Menu Bar").Enabled = False

Then, I told my forms to use my toolbars. Now, this works quite nice. But, when mistakenly touching the "Alt" button, the menu reappears, menu item by menu item. Same story for the "F10" button. First you see a small rectangle, then when you start moving the cursor buttons, the whole menu becomes visible AND ACTIVE!

So I've tried a few things. I chose to disable ALL commanbars. This however, resulted in a disappearing of commandbars for the next person to use Access97, whether this person used my app or not. Next, I created my own menubar and told my app to use it, but that meant constantly two 30 point bars on screen, one menu bar and one filled with toolbars, not forgetting the 12 point title bar that should not be removed at all. Three of these bars clutter my screen and the screen really isn't that big. Besides, the menubar is hardly filled (two items) so it takes up empty room.

Question: do you know an elegant way to dispose of this built in menu bar, so that even a misfortunate "Alt" button doesn't activate it? The "F10" key can be silenced using an AutoKeys macro, but the "Alt" key cannot. Also, keep in mind that not every person has a Developpers Kit (I don't), so not everyone is able to create runtime versions (I'm not). However, I'd like to know whether runtime versions show the same problem or not.

Imagine!
0
Comment
Question by:OmegaJunior
  • 2
4 Comments
 
LVL 9

Expert Comment

by:perove
ID: 1963540
I belive this is a bug in access. But to give you a solution to prevent this , just create a macro with no commands init. Call it emptymenu then put in emptymenu in the menubar property for the form.
(you cannot see it in the list but ...)
perove
0
 
LVL 3

Author Comment

by:OmegaJunior
ID: 1963541
Thank you, perove,

But this kind of wavering already came to mind. It works, but it is not elegant. What I'm looking for is not a workaround, it's a solution. Workarounds have to be unworkarounded, and if the app isn't shut down correctly, I can't get the settings back the way they should.

Imagine!
0
 
LVL 10

Accepted Solution

by:
brewdog earned 100 total points
ID: 1963542
Have you thought about setting the KeyPreview property for your forms to True, and then trapping the KeyPress event for an "Alt"? You should be able to just write something like a simple

If KeyCode = vbAlt then
End if

I am not positive that that syntax works, but it's worth a shot.

If your users are able to use the Alt key for other commands on forms, you'd probably need to see if they were pressing Alt and something else.

brewdog
0
 
LVL 3

Author Comment

by:OmegaJunior
ID: 1963543
Greetings, brewdog,

This works!

KeyPreview = True

Altkey needs to be handled: it isn't vbKeyAlt or something, Access didn't create any constants for it. But it has an integer KeyCode: number 18!

So, in KeyDown, I code:

If KeyCode = 18 then KeyCode = 0

and the alt key is disabled!

Now to all other users of Access: keep it in mind! This menu bar breach is a serious breach in Access security!

You want to know why I didn't come up with the KeyPreview property? I use the Dutch version. Translated from Dutch, the name of this property is KeyExample (Dutch: "Toetsvoorbeeld"). Seriously Microsoft, an example ain't no preview in this context!

More translation problems: KeyCode constants are words Access uses to name keys from the keyboard. It is translated, however, as if the Key were a key to open a lock or a door, or as if it were some sort of primary key. I hope Microsoft takes care of their translations in the NEAR future.

Many thanks, brewdog,

Imagine!
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Field behavior for "locked" form 12 29
data analyst 3 50
Search Form with Run Time Error 3075 1 23
Improving performance of a query that uses a subquery 9 32
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now