How to Write an If Statement in Access

how to do an if statement

"If" statements can evaluate "true" or "false" conditions and perform actions based on those conditions. These statements can be broken down into two types: "If-Then" statements and "If-Then-Else" statements. "If-Then" statements perform a set of actions only when the statement's conditions are met. "If-Then-Else" statements perform one set of actions if the statement's conditions are met and a different set of actions is the conditions are not met. "If" statements can be entered using the Visual Basic Editor or the Expression Builder.

Visual Basic If-Then Statements

Click the "Database Tools" Tab and select "Visual Basic." This will open the Visual Basic Editor.

Open the module to which you will be adding the "If" statement.

Click "Insert" on the menu bar, and then select "Procedure."

Type the name of the procedure in the name box.

Select "Sub" followed by either "Public" or "Private" for the scope.

Click "OK." This

will open the editor box with "Sub" and the "Name" on the first line. Press Enter.

Enter the actions you would like function to perform if the result is evaluated as "true". Repeat this step as many times as needed, with each action on a separate line. Press Enter.

Visual Basic "If-Then-Else" Statements

Click "OK" to open the editor box with "Sub" and the "Name" on the first line. Press Enter.

Type "If [Your condition here] Then". Press Enter.

Enter the actions you want function to perform if the result is evaluated as "true". Repeat this step as many times as needed, with each action on a separate line. Press Enter.

Enter the actions you want the function to perform if the result is evaluated as "False". Repeat this step as many times as needed, with each action on a separate line. Press Enter.

Expression Builder "If" Statement

Source: ehow.com

Category: Forex

Similar articles: