Epi Info™ User Guide

Check Code: Customizing the Data Entry Process

Check Code Commands

Searching for Records – Using the AUTOSEARCH command

The Autosearch command automatically searches for an existing record that matches the entered values and notifies the user. A choice is then offered between editing the matching record or continuing with data entry in the new record. Duplicate records are detected and may be prevented with the AutoSearch command. For this example, we will incorporate the Autosearch command on the CaseID field.

  1. From Form Designer, Open the FoodHistory_NoCheckCode form in the EColi.prj.
  2. Click Check Code or select Tools > Check Code Editor. The Check Code Editor opens.
  3. From the Choose Field Block for Action section, expand the node for the page where the CaseID field is located, which in this example is Page 1.
  4. Expand the node for the field CaseID.
  5. Double click on the after event.
  6. A block of code for the CaseID field is created and displayed in the Check Code Editor.
    Autosearch block for action

    Figure 3.25: AutoSearch Block for Action


  7. The code appears in the Check Code Editor.
    Check Code Sample showing the After Block shell

    Figure 3.26: AutoSearch Block Code


  8. From the Add Command to Field Block list box, click Autosearch. The Autosearch window opens.
  9. Select the variable(s) to be searched during data entry. In this example, select CaseID.
    Autosearch command dialog

    Figure 3.27: Auto Search dialog box


  10. Click OK. The code appears in the Check Code Editor window.
    Check Code Sample showing the AUTOSEARCH command

    Figure 3.28: AutoSearch Check Code Command


  11. Click the Verify Check Code button from the Check Code Editor.
  12. Click the Save button from the Check Code Editor.
  13. Click Close to return to the form.


When a duplicate record is entered in the Enter Data tool, the Autosearch dialog box opens with all the matching records listed. To view the potential duplicate record, double-click the arrow that appears next to the record. The field where the potential duplicate was entered is cleared. Alternatively, click Cancel to remain on the current record and accept the duplicate value. To display other variables when a matching record is found, add the variable names after the DISPLAYLIST parameter (i.e. Last Name, First Name and Date of Birth as shown below)


Field CaseID
//add code here


In the check code above, the autosearch will be done on the field CaseID and if any matching records are detected, the fields CaseID, LastName, FirstName and DOB will be displayed on the grid.


Autosearch Results dialog

Figure 3.29: AutoSearch Results

Note: For more information on using Autosearch, please see the Autosearch topic in the Command Reference.