Microsoft Access VBA Tutorials for self-paced learning, Class Modules, SQL Techniques, and AI Integration Guides.

Showing posts with label Menus. Show all posts
Showing posts with label Menus. Show all posts

Restoring disabled Full Menus Access2007

Restoring disabled Full Menus Access2007

When developing an application, even for personal use, it is important to design each object as if it will be used by someone else. Only then will we take a careful look at each control’s functionality, strengths, and limitations. Users may not interact with a table, form, or report the way we envision. They might enter incorrect data, attempt unintended actions, or experiment with the design of controls and forms.

For example, consider a Date of Birth or Invoice Date field on a form. If the field allows any date value, users may accidentally enter invalid dates, such as a future date. To prevent such errors, we should enable built-in validation checks on the field, alert users to mistakes, and enforce the entry of valid values.

Data Field Validation Checks.

We can enforce this by setting the Validation Rule and Validation Text properties of the date field.

The Validation Rule property can be set to <Date() to accept only date values earlier than today, suitable for a Date-of-Birth field.

If you want to restrict entries to a reasonable range, for example, limiting ages to 100 years, you can use a rule like:

>=(DateAdd("yyyy",-100, Date())) And <Date()  

This ensures that the entered date is not more than 100 years in the past and not a future date.

The Validation Text property can be set with a message such as:

"Future date is invalid, and Age Limit is 100 years"

It is recommended to implement this directly on the Table field rather than just on the Form, as this ensures data integrity regardless of how the data is entered.

Preventing Changes to Important Objects.

Equally important is ensuring that users cannot modify critical objects such as Forms, Queries, Reports, Macros, and VBA code. This is where User-Level Security in Microsoft Access comes into play. 

Note, however, that this security feature is available only in Access 2003 and earlier versions.

Keep Users' Freedom within Limits.

Another effective way to prevent users from straying into unintended areas is to create custom menus and toolbars for your application, while disabling all built-in menus and toolbars. This ensures that users cannot access object designs or other sensitive features through the default Access interface.

Once your customized menus and toolbars are in place, you can disable the built-in menus by removing the relevant check marks in the Access Options. This creates a controlled environment, allowing users to interact only with the parts of the application you intend them to use.

Caution: Take a backup of the database before making the following changes otherwise you may not be able to get back into the database for making design changes yourself later.

Select Office Button  -> Access Options  -> Current Database  -> Ribbon and Toolbar Options

Remove check marks from the following options:

  • Allow Full Menus
  • Allow Default Shortcut Menus
  • Allow Built-in Toolbars

After removing the check marks, you must close and reopen the database. Now, only the customized menus and toolbars you created will be available to the user.

However, your database objects—Forms, Reports, etc.—are still not fully protected from unauthorized changes. While users cannot right-click an object in the Navigation Pane to enter Design View, they can still access objects via the VBA Modules. For example, they might browse the Navigation Pane, select a Form or Report, and then choose the View Object option.

In the VBA Navigation Pane, Forms and Reports associated with Class Modules are visible to users. To limit access, you can hide these objects by right-clicking in the Navigation Pane and setting the Hide option.

For more comprehensive protection, you can also disable the Navigation Pane entirely by removing the check mark from Display Navigation Pane, in addition to disabling the built-in menus as explained earlier. This ensures that users cannot navigate to the module or object views at all.

Unless the user is very clever, you can consider your database objects reasonably safe—but not completely secure from a determined or knowledgeable individual. For instance, anyone familiar with keyboard shortcuts can open the VBA Editor by pressing ALT+F11. From there, the story unfolds on its own. Even if you hide the Navigation Pane within the VBA window, it can still be accessed via the Object Browser button on the toolbar.

Since User-Level Security is no longer available in Access 2007 and later versions, these are the methods you can use to implement security in an Access database.

Once you remove the full menus option, it becomes difficult to make design changes to Forms, Reports, or other objects. For this reason, it is highly recommended to take a backup before implementing these security measures.

Even during the design phase, make it a regular practice to create Database backups. This ensures that if your database becomes corrupted or is accidentally deleted at any stage, your work is safe, and you do not risk losing all your progress.

Restoring Full Menus.

If you want to restore the full menus, there is a simple trick to regain access to the database and re-enable the Allow Full Menus option—without going through the Office Button menu directly.

  1. Open the database.

  2. Press ALT+F11 to display the VBA Window

  3. Press CTRL+G to display the Debugging Window (Immediate Window).

  4. Type the following command in the Debug Window and press the Enter key:

    CurrentDb.Properties("AllowFullMenus").Value = True
  5. Close and reopen the database.

Now, you can navigate to Access Options through the Office Button (top-left corner) and make changes in Options there.

Technorati Tags:

Earlier Post Link References:

Share:

Create Menus with Macros-2

Create Menus with Macros-2. - Access 2003

Continued from last week’s article: [Create Menus with Macros] – please go through this Article before continuing.

In the previous article, we learned how to create a simple Shortcut Menu for Forms using Macros. This week, we will take this concept further and demonstrate how to create a Toolbar Button and a Menu Bar item using Macro-based menus.

New Macro: macProcess.

But before all that, we need to implement some modifications to our earlier shortcut menu to add a menu group item with a few options.

  1. Open a new macro in the design view.

  2. Select MsgBox from the drop-down list in the Action Column.

  3. Type Proceed with Report Data Processing? In the Message control under the Action Argument list.

  4. Select Critical from the drop-down list in the Type control.

  5. Type Report Processing in the Title control.

    Note: The purpose of this macro is to hold a series of actions, such as running action queries (Make-Table, Append, Update, Delete), executing other macros, or calling VBA routines to prepare data for reports. In this example, we are using a message box to display a sample message. In practice, you should design your menus with actions tailored to specific needs of your application.

  6. Save the Macro named macProcess and close it.

    The macSubMenu Macro.

  7. Click on New to open another macro in Design View.

  8. If the Macro Name Column is not visible, then select Macro Name from the View Menu.

  9. Type &Form in the Macro Name column of the first row and select OpenForm from the drop-down list under the Action Column.

  10. Select an existing Form in the Form Name control using the drop-down control.

  11. Type Process & Data in the Macro Name column in the second row and select RunMacro in the Action Column.

  12. Type macProcess (or select it from the drop-down list) to insert the process macro that we have created in step 6.

  13. Type &Report in the Macro Name column in the third row and select OpenReport in the Action column.

  14. Select an existing Report from your application in the Report Name control.

  15. Select Print Preview in the View control.

  16. Save the macro named macSubMenu and close it.

    Modify Macro: mcrShortCut.

  17. Open the macro mcrShortCut that we created last week.

  18. Type MenuGroup in the next row (as shown in the image given below) and select the AddMenu option from the drop-down list under the Action column.

  19. Type Form/Report in the Menu Name control below the Action Arguments.

  20. Type macSubMenu (or select from the drop-down list) in the Menu Macro Name control.

  21. Save and close the macro mcrShortCut.

  22. If you recall the Form to which you attached the shortcut menu in last week’s exercise, open that form in Normal View and right-click anywhere on it to display the Form/Report submenu we added earlier. If you don’t remember, simply open any of your existing forms in Design View to continue.

  23. Display the Property Sheet (View -> Properties or press ALT+Enter).

  24. Click on the Other Tab.

  25. Set the Shortcut Menu Property value to Yes.

  26. Set the Shortcut Menu Bar Property value to macMenu (you can select the macro from the drop-down list).

  27. Save and close the Form.

    The Shortcut Menu Trial Run.

  28. Open the Form in Normal View.

  29. Right-click on a field to display the Shortcut Menu. The newly added Group Menu will appear at the end of the Menu description Form/Report.

  30. Place the mouse over the Form/Report menu group to display its Sub-Menu items.

The menu definition now remains in Macros, and we are directly using it on Forms.  But we can convert the Menu Macro into a regular:

  • Menu Bar (like File, Edit, etc.) OR
  • Toolbar  OR
  • Shortcut Menu.

If you would like to convert this macro menu into a Menu Bar, then we must make a small change in the macMenu macro.

Converting Macro into Menu Bar.

  1. Open macMenu in design view.

  2. Type myMenu in the Menu Name control under Action Arguments.

  3. Save and close the macro.

  4. Click on the macMenu macro to select it.

  5. Highlight the Macro in the Tools Menu.

  6. Click on the Create Menu from Macro Option.

    A Menu Bar will appear at the top labeled myMenu.

  7. Click on the myMenu option to display the menu options for which we have created macros.

Note: You should not attempt to convert the same macMenu to a Toolbar Menu; a name conflict may take place.

Quick Toolbar Button.

Tip: To create a quick Toolbar Button with the same set of macros, do the following:

  1. Create copies of macros: macMenu, mcrShortCut, and macSubMenu, and rename them to mac_Menu, mcr_ShortCut, and mac_SubMenu.

  2. Open the mcr_ShortCut macro in design view.

  3. Click the last line, change the Menu Macro Name control value to mac_SubMenu, save, and close the Macro.

  4. Open the Mac_Menu macro in design view.

  5. Change the Menu Name control value to myToolbar.

  6. Change the Menu Macro Name control value to mcr_ShortCut, save, and close the Mac_Menu Macro.

  7. Click on the Mac_Menu Macro to select it.

  8. Highlight the Macro in the Tools Menu to display its Options.

  9. Click Create Toolbar from the Macro option to convert the macro into a Toolbar; the myToolbar button will appear near the existing Toolbar label myToolbar.

  10. You may click on it to display the Menu.

Share:

Create Menus with Macros

Create Menus with Macros - MS Access 2003.

We learned earlier how to create Menus and toolbars through the Toolbars -> Customize options.  If you would like to have a second look at them, then the links are given below:

There are other methods for creating simple custom menus for Forms/Reports in your Applications.  This time, we create a Shortcut Menu with Macros and attach it to a Form.

Sample Demo Run.

  1. Select the Macro Tab on the Objects pane.

  2. Click New to open a new Macro in Design View.

  3. If the Macro Name Column is not visible, click the Macro-Name Toolbar Button (the xyz label) that displays the name column.

  4. Type 'Clo&se' under the Macro Name column in the first row.

  5. Select Close from the drop-down list under Actions.

  6. Type &Preview in the second row under Macro Name.

  7. Under Action, select the OpenReport option from the drop-down list.

  8. In the Property Sheet under Action Arguments, select a Report from your list of Reports (I selected the Employees Report in the sample image given above) in the Report Name Property.

  9. Select Print Preview in the View Property.

  10. Type &Form in the third row under the Macro Name column.

  11. Select  Open Form in the Action Column.

  12. Select an existing Form's name from the Form Name Property drop-down list.

  13. Select the Form in the View property.

  14. Type a dash (-) character in the next row under the Macro Name column.

  15. Type &GotoNext in the fifth row under the Macro Name column.

  16. Select GotoRecord in the Action Column.

  17. Type &Minimize in the sixth row under Macro Name.

  18. Select Minimize from the drop-down list in the Action Column.

  19. Save the Macro named mcrShortCut and close it.

You can add as many commands or actions, like opening Queries or running Programs, to your menu for the convenience of your Application Users.

Defining Macro as Menu.

Our work on the Macro Menu is complete, but a few more actions are left to define the Macro as a Menu. 

  1. Open a new macro in the design view.

  2. Select AddMenu from the drop-down list in the Action Column.

  3. Leave the Menu Name Property Blank. This is used for Group Menu Names when you have group Menus with different sets of actions.  In this case, the Macro will have more than one AddMenu Action line with a different set of Menu Macros.

  4. Select mcrShortCut in the Menu Macro Name Property.

  5. Save the macro named mcrShortCutMenu.

  6. Open one of your Forms in Design View (don't open the form that you have used in the OpenForm action in the first macro).

  7. Display the Form's Property Sheet (View -> Properties).

  8. Set the following Property Values of the Form as given below:

    • Shortcut Menu = Yes
    • Shortcut Menu Bar = mcrShortCutMenu
  9. Save the Form.

  10. Open the Form in a normal view.

  11. Right-click on the Form to display the Shortcut Menu.  See the sample image given below:

Try out the options displayed in the Shortcut Menu.

We can create Shortcut Menus, Toolbars, and Menu Bars too.  This we will learn Next.

Share:

PRESENTATION: ACCESS USER GROUPS (EUROPE)

Translate

PageRank

Post Feed


Search

Popular Posts

Blog Archive

Powered by Blogger.

Labels

Forms Functions How Tos MS-Access Security Reports msaccess forms Animations msaccess animation Utilities msaccess controls Access and Internet MS-Access Scurity MS-Access and Internet External Links Queries Array Class Module msaccess reports Accesstips msaccess tips WithEvents Downloads Objects Menus and Toolbars MsaccessLinks Process Controls Art Work Collection Object Property msaccess How Tos Combo Boxes ListView Control Query VBA msaccessQuery Calculation Dictionary Object Event Graph Charts ImageList Control List Boxes TreeView Control Command Buttons Controls Data Emails and Alerts Form Custom Functions Custom Wizards DOS Commands Data Type Key Object Reference ms-access functions msaccess functions msaccess graphs msaccess reporttricks Command Button Report msaccess menus msaccessprocess security advanced Access Security Add Auto-Number Field Type Form Instances ImageList Item Macros Menus Nodes Recordset Top Values Variables msaccess email progressmeter Access2007 Copy Excel Expression Fields Join Methods Microsoft Numbering System RaiseEvent Records Security Split SubForm Table Tables Time Difference Utility WScript Workgroup Wrapper Classes database function msaccess wizards tutorial Access Emails and Alerts Access Fields Access How Tos Access Mail Merge Access2003 Accounting Year Action Animation Attachment Binary Numbers Bookmarks Budgeting ChDir Color Palette Common Controls Conditional Formatting Data Filtering Database Records Defining Pages Desktop Shortcuts Diagram Disk Dynamic Lookup Error Handler Export External Filter Formatting Groups Hexadecimal Numbers Import Labels List Logo Macro Mail Merge Main Form Memo Message Box Monitoring Octal Numbers Operating System Paste Primary-Key Product Rank Reading Remove Rich Text Sequence SetFocus Summary Tab-Page Union Query User Users Water-Mark Word automatically commands hyperlinks iSeries Date iif ms-access msaccess msaccess alerts pdf files reference restore switch text toolbar updating upload vba code