Epi Info™ User Guide
Check Commands: GOTO
This command can be used alone or in an IF statement to transfer the cursor to a named variable field.
- The <field> can be a field name in the current form. The field may be on the current page or another page.
- The <page-position> can be:
- the number of the page such as “GOTO 4” to make the cursor go to the 4th page of the form.
- a relative page position such as “GOTO +2” to advance forward 2 pages from the current page.
Event and Description
- +1 Automatically saves the current page if changes have been made, and goes to the next page.
- -1 Automatically saves the current page if changes have been made, and goes to the previous page.
- <page number> Automatically saves the current page if changes have been made, and goes to the page indicated by the number.
- <variable name> Goes to the variable indicated. Automatically saves the current page if changes have been made, if the variable is on another page.
GOTO will be ignored if it is in the Before or After Record event. The GOTO command skips all fields that are unavailable for data entry or Read Only.
GOTO should be used to skip several fields or pages to expedite data entry.
It is not recommended to use GOTO to return to the field that triggered the GOTO command as this can result in an endless loop.
GOTO should not be used in lieu of setting the proper tab order. If there are a few fields or a group that needs to be skipped, an alternative is to use DISABLE or HIDE on the fields to be skipped. These alternative commands make the fields unavailable and the cursor will go to the next available field in the tab order.
Example 1: The form will skip directly from one field to another based on certain user input. The example assumes a form exists that has the following fields: DoYouSmoke (Yes/No), PacksPerDay (Numeric), and HeartDisease (Yes/No). The code below would appear in the AFTER section of the DoYouSmoke field.
Field DoYouSmoke After IF DoYouSmoke = (+) THEN GOTO PacksPerDay ELSE GOTO HeartDisease END-IF End-After End-Field
Example 2: You will be taken to the second page on the form based upon an answer provided to a question on lung disease. The example assumes a form exists that has two pages and the following field: LungDisease (Yes/No). The code below would appear in the AFTER section of the LungDisease field.
Field LungDisease After IF LungDisease = (-) THEN GOTO 2 END-IF End-After End-Field
Example 3: You will be taken to the page immediately following the one they are on currently. The example assumes a form exists that has two or more pages and the following field: DOB (Date) on page 1. The code below would appear in the AFTER section of the DOB field.
Field DOB After IF NOT DOB = (.) THEN GOTO +1 END-IF End-After End-Field