Epi Info™ User Guide

Command Reference


Check Commands: Before and End-Before

Description
This command enables Check Commands to be executed before data entry occurs in a field, before data entry occurs on a form or page, or before data entry occurs on a record.

Syntax
Before

//add code here

End-Before

  • Before and End-Before are only used in Check Code.

Comments
The Before command determines when commands are run.  Commands between Before and End-Before run when upon accessing a form, record, page, or field.  For fields, the commands within the Before block are run immediately when the cursor goes into the field.  If the cursor cannot enter the field, such as when the field is disabled or read-only, then commands in the Before block will not run.

Before/End-Before block is not applicable for fields that cannot receive the cursor such as Command Buttons, Relate fields, and Option fields.

If Before/End-Before is used with Record, then data in fields are not be available for conditional statements such as If/Then.

Example
The following commands demonstrate the Before/End-Before and After/End-After command blocks.  Before data entry, the Date Of Onset field is highlighted.  After data entry, if the Date Of Onset field is blank, then the field is highlighted, otherwise the field is unhighlighted (highlight is removed).

Field DateOfOnset
   BEFORE
      HIGHLIGHT DateOfOnset
   END-BEFORE
   AFTER 	
      IF DateOfOnset = (.) THEN
         HIGHLIGHT DateOfOnset
      ELSE
         UNHIGHLIGHT DateOfOnset
      END-IF
   END-AFTER
End-Field