Access uses the macro control program 3. Use criteria in Macros _access

Source: Internet
Author: User

In some cases, you might want to perform one or more actions in a macro only if a specific condition is true. For example, if you use a macro to validate data in a form, you might want to display the appropriate information to respond to some of the record's input values and another to respond to different values.     In this case, you can use conditions to control the process of the macro. The condition is a logical expression. The macro executes along a different path depending on the true or false condition result. If this condition turns out to be true, Microsoft Access performs the action in this row. Type the ellipsis (...) in the Condition column of the action that follows this action. , you can make Microsoft Access perform these actions when the condition is true, or if the result of this condition is false, Microsoft Access ignores the action and the action is followed by an ellipsis (...) in the criteria field. and moves to the next action that contains another condition or an empty condition field.

Create a form, add a text box, name "Enter a number text box", and add a confirmation button. Click the event that determines the button's properties/Click the Builder button to the right, select Create macro, and give macro a macro name, such as Macro 3.

The figure above is the Design view for Macro 3. This macro will implement a different message based on the number of different numbers that the user entered in the Enter numeric text box. Click the Criteria button on the toolbar

, add a conditional column to the macro.     The first line in the figure shows a message "you entered a number less than 10" when the 0 < [Enter number text box] < 10 o'clock.     The second line shows a message "you entered a number greater than 10 and less than 20" when you < [Enter the number text box] < 20 o'clock. The third line shows a message "you entered a number less than 20 and less than 30" when < [Enter the number text box] < 30 o'clock. Close the Design view of the macro and save the macro 3.

This is the effect of the form runtime, when a number 15 is entered, the message box appears as shown

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.