Autoexec macro of access

Source: Internet
Author: User

Today, my colleague sent me an access file and opened it and jumped out of a form. I want to see some properties of this form. I didn't expect the file to be automatically closed after I pressed the design view button. # % $ *@! & # ^ ?, Challenge me!

Open the file again and clickToolsMenu>StartupIn general, the form started when the access file is opened is set here, but there is nothing in the main here. I originally wanted to cancel the form opening here.

Let's take a look at the other ones. Open the macro list and you will see a suspicious macro named autoexec. According to the Help File of access, when the access file is opened, the macro command with this name will be searched. If it is found, the macro command will be executed. You can use this special macro to execute some actions when the database is just opened. (You can also use a special macro named autoexec to carry out an action or series of actions when your database first opens. when you open a database, Microsoft Access looks for a macro with this name and, if it finds one, runs it automatically .)

TIPS: the settings in startup are executed before the autoexec macro.

The main definition of this file is the macro named autoexec. Executing the OpenForm command in it is the form that jumps out when I open it.

But why access when I switch to "design view "?ProgramWill it be turned off? I first change the autoexec macro name so that the form will not be opened when the file is opened. Then I check the form attributes and find that the onclose event is associated with another macro command. This macro executes the "quit" action, exit the program. No wonder that switching a form from form view to design view triggers the onclose event. The main logic is to open the form at the beginning. As long as you close the window, the program exits.

Tip: add the "msgbox" action to the macro associated with the onclose event. You can confirm that the onclose event is triggered by switching from "form View" to "design view.

What if we use the "quit" action directly in the autoexec macro? Then we can see nothing, because the access program just opened and exited. But rest assured that the access program will not let such a prank succeed, Access provides a way to bypass this macro. (If you don't want to run the autoexec Macro when you open the database, hold down the Shift key when the database opens .)

Hold down the Shift key when opening the access file. Remember to keep holding down, no matter how many prompts you see.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.