Access using macro control program 3. Use Conditions in macros

Source: Internet
Author: User
Access using macro control program 3. Use Conditions in macros

Access using macro control program 3. Use Conditions in macros


In some cases, you may want to perform one or more operations in a macro only when the specified condition is true. For example, if a macro is used to verify data in a form, the corresponding information may be displayed to respond to certain input values of the record, and the other information to respond to different values. In this case, you can use conditions to control the macro process. The condition is a logical expression. Macros are executed along different paths based on the true or false condition results. If this condition is true, Microsoft Access performs the operation in this row. Enter the ellipsis (…) in the condition column of the operation that follows this operation (...), Microsoft Access can perform these operations when the condition is true. If the result of this condition is false, microsoft Access ignores this operation and is followed by a ellipsis (…) in the condition field (...) And move to the next operation that contains other conditions or empty "condition" fields.
Create a form, add a text box, name it "input number text box", and add a confirmation button. Click the OK button property event/click the generator button on the right, select create macro, and create a macro name for the macro, such as "macro 3 ".
Is the design view of macro 3. This macro displays different messages based on different numbers entered in the [enter number text box. Click the "condition" button on the toolbar.
To add a condition column for The Macro. The first line in the figure indicates that when 0 <[enter a number text box] <10, a message "you entered a number less than 10" is displayed. The second line indicates that when 10 <[enter a number text box] <20, a message "you entered a number greater than 10 and less than 20" is displayed. The third line indicates that when 20 <[enter a number text box] <30, a message "you entered a number smaller than 20 and less than 30" is displayed. Close the macro design view and save macro 3.
This is the result of the form running. When a number of 15 is entered, the message box will be displayed.

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.