Link to home
Start Free TrialLog in
Avatar of Mach1pro
Mach1pro

asked on

Keep Hidden forms hidden

I have a database where a couple of forms run in the background and are hidden from the user including the database window. The problem is that you can go to the menu bar select  Window|Unhide and then select to unhide these forms. Is there a way to keep these forms from showing up in the menu bar Without creating a custom menu bar?
ASKER CERTIFIED SOLUTION
Avatar of bvdm23
bvdm23

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tokerblue
tokerblue

You can still get into the database background by holding down "Shift". What are you trying to protect? The form design? Code?

Think about using a MDE file.
Here is some code to disable individual commands on the Menu Bar put this code on the OnOpen event of any for that you load where you don't want the menu command to be available. The following code disables the Print command but you can modify itto disable any other menu bar command as well.

'Disable Print Command on menu bar
   Dim CBarMenu As CommandBar, CBarTool As CommandBar
   Dim CBarCtl As CommandBarPopup
   Set CBarMenu = CommandBars("Menu Bar")
   Set CBarMenu2 = CommandBars("Form View")
   Set CBarMenu3 = CommandBars("Print Preview")

   Set CBarTool = CommandBars("File")

         CBarTool.Controls("Print...").Enabled = False
         CBarMenu2.Controls("Print").Enabled = False
         CBarMenu3.Controls("Print").Enabled = False

'Re-Enable Commands
'         CBarTool.Controls("Print...").Enabled = True
'         CBarMenu2.Controls("Print").Enabled = True
'         CBarMenu3.Controls("Print").Enabled = True


If you don't want the user to be able to unhide the database window by pressing F11 you can do 2 things.

1) In Tools...Startup, uncheck "Use Access Special Keys" This will disable pressing F11 to show database window.

2) add this code to your OnKeyDown event of the fields on your form to disable just the F11 Function key.

Select Case KeyCode
        Case vbKeyF10
        'If KeyCode is F11 then nullify
            KeyCode = 0
End Select


Here is some code to disable individual commands on the Menu Bar put this code on the OnOpen event of any for that you load where you don't want the menu command to be available. The following code disables the Print command but you can modify itto disable any other menu bar command as well.

'Disable Print Command on menu bar
   Dim CBarMenu As CommandBar, CBarTool As CommandBar
   Dim CBarCtl As CommandBarPopup
   Set CBarMenu = CommandBars("Menu Bar")
   Set CBarMenu2 = CommandBars("Form View")
   Set CBarMenu3 = CommandBars("Print Preview")

   Set CBarTool = CommandBars("File")

         CBarTool.Controls("Print...").Enabled = False
         CBarMenu2.Controls("Print").Enabled = False
         CBarMenu3.Controls("Print").Enabled = False

'Re-Enable Commands
'         CBarTool.Controls("Print...").Enabled = True
'         CBarMenu2.Controls("Print").Enabled = True
'         CBarMenu3.Controls("Print").Enabled = True


If you don't want the user to be able to unhide the database window by pressing F11 you can do 2 things.

1) In Tools...Startup, uncheck "Use Access Special Keys" This will disable pressing F11 to show database window.

2) add this code to your OnKeyDown event of the fields on your form to disable just the F11 Function key.

Select Case KeyCode
        Case vbKeyF10
        'If KeyCode is F11 then nullify
            KeyCode = 0
End Select


Avatar of Mach1pro

ASKER

ACSPanama,
The F11 key is already disabled. That's not an issue.
Your code doesn't compile. Evidently it requires an additional reference that I don't have checked. I'm using AK2000.

bvdm23,
Your answer appears to work, but I'm wondering if it is going to disable other features that users in my database will need.
I would prefer to only disable the window feature. I also wonder if some code may fail when this feature is disabled eg.
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
It won't disable the features you mentioned because it is only intended to disable some menu features you can use to avoid the users from directly make changes to the DB when you are using e.g a switchboard
The code should compile in 2000. It copiles in my DataBase to a .mde perhaps you need to change/update your Reference to the Microsoft DAO Object Library, but anyway here is a link to Microsoft Knowledge Base Article - 160293 which tells you how to disable menu commands in Access 97, but also works in Access 2000 & Access 2002(XP).

http://support.microsoft.com/default.aspx?scid=KB;en-us;q160293