How to create macros in Access

Microsoft Access is one of the most common application software programs that can be used to build lots of database applications. Among others, such as Powerpoint for designing and presentations, Excel for most mathematical operations, Word for editing documents, and Access, they all help a lot when it comes to database management.
Loading, Ms. Access

  1. Right-click the ‘Macros’ folder in the ‘Navigation Pane’.
  2. Click on ‘New Macro’ to open the Macro window.
  3. Name your macro and assign it a macro shortcut.

To add actions to your macro, you can use the following code examples as a guide:

Replace the values inside the quotation marks with your own values.

Example 1: Open a form.

vba
Download
Copy code
DoCmd.OpenForm “YourFormName”
Example 2: Close the active form.

vba
Download
Copy code
DoCmd.Close acForm, Me.Name
Example 3: Run a query.

vba
Download
Copy code
DoCmd.OpenQuery “YourQueryName”
Example 4: Open a report.

vba
Download
Copy code
DoCmd.OpenReport “YourReportName”, acViewNormal
Once you have finished writing your macro, close the macro window.

To run your macro, you can either click on the ‘Macros’ button on the ribbon and select your macro or press the shortcut key you assigned earlier.

About Author


Discover more from SURFCLOUD TECHNOLOGY

Subscribe to get the latest posts sent to your email.

Leave a Reply

Your email address will not be published. Required fields are marked *

Discover more from SURFCLOUD TECHNOLOGY

Subscribe now to keep reading and get access to the full archive.

Continue reading