Epi Info™ User Guide

Form Designer


How To: Use the Codes Field

A Codes field designates the available options on a form based on the user’s response to a question. Based on the value selected from a drop-down list, other field(s) are populated with predetermined values. At least two fields must exist; one which holds the selection code, and another to receive the value of the code. The first field holds the selection code in a drop-down list while subsequent fields are Read Only and are populated based on the values in the code table. The Codes field allows for more efficient data entry by the user. This field type is not supported on Web Survey. The following figure provides an example of how a Codes field appears in Enter (circled in blue) based on the Surveillance form of the Sample project.

Image showing an example of a Codes field in use. The codes field will prepopulate other fields based upon the users choice, thus saving time and increasing efficiency of entry

Create a New Codes Table

  1. Open the Codes Field Definition dialog box.
  2. Enter the Question or Prompt. The text entered in this field will display on the canvas and prompt the user to enter a response.
  3. Click in the Field Name text box or press the tab key. Epi Info automatically suggests a field name based on the Question or Prompt, however, it is very important that field names be short, intuitive, and usable. The field name is used for data validation in Check Code and when doing analyses. Field names cannot start with a number or contain any spaces or non-alphanumeric characters (except the underscore character “_” is permitted).
  4. Select the field(s) to be linked from the Select field(s) to be linked section. To select multiple fields, hold down the CTRL key and click each field.

Note: It is best to simplify the field name at this time. Field names cannot be changed after data collection starts.

Image showing the Codes Field Definition Dialog box.
  1. Click on the Data Source browse button.
Image showing the Codes Field Data Source Dialog box.
  1. Click Create New. A spreadsheet opens for you to enter the values for the Codes field and Linked fields..
Image showing the Codes Field Data Source box after clicking Create New button.
  1. The left-most column displays the selection field(s) chosen in the Fields Definition dialog box.
Image showing the Codes Field Data Source box with a few rows entered.
  1. Each column to the right lists the field(s) to receive the codes based on the value of the selection field.
  2. Enter the codes for each field.
  3. Press the Tab key to move to the next field, or to the next row if at the end of a row.
  4. Click OK to accept the codes for each field.
  5. Existing tables can also be used to create code tables.
  • Click Create New from Existing (takes a copy of the selected table, changes to the original table will not affect the new table) or Use Existing (establishes a connection between the selected table and the new table, any changes made to the original table will modify the new table)
  • Select a table from the drop-down list.
  • Click OK.

For information on other attributes that may be available, see the topic on Field Attributes.

  1. Click OK to close the Field Definition dialog box and place the fields in the form.
  2. To test the code table, open the Enter tool and verify that both fields populate based on the drop-down list selection.

Create Cascading Drop-Down Fields

Cascading Drop-Down fields are essentially two or more Code, Legal Value, or Comment Legal fields linked together in such a way as to filter each subsequent field based on the value selected in prior fields. In the example described below, the drop-down field for State, filters the drop-down field, County, to show only those counties that exist in the selected State. When County is selected, the drop-down field for Hospital is shown with only the hospitals located in the selected county.

In order to create Cascading Drop-Down fields, you need to have a table completed with all values for the linked fields that can be imported into Epi Info™ 7. The Excel spreadsheet shown below, named ‘codeHospital’, is an example of such a table. When importing this table into your Epi Info™ 7 project, the table name must contain the prefix “code”, as in this example, “codeHospital”.

Image showing an Excel spreadsheet of the table to be used for Cascading Codes with columns for State, County, and Hospital.

To add Cascading Drop-down fields, complete the following steps:

  1. Add the first Codes field to the page, but don’t link the field to other fields, yet. You will do this in later steps. For this example, we named the field StateName.
Image showing the Codes Field Definition dialog box with the field name 'StateName'.
  1. Add another Codes field to the page. Again, don’t link the field to other fields, yet. In this example, we named the second field County. Repeat this step for all but the last field in your cascading sequence. In this example, we have only three fields to link, so the next field will be our last.
  2. Add the last field in our cascading sequence. The last field should be a type other than a Codes field, such as Legal Value or Comment Legal. Since no other fields will be linked to this last field, you don’t want to use a Codes field. In our example, we have two Codes fields named ‘StateName’ and ‘County’, and one Legal Value field named ‘Hospital’.
Image showing the canvas with fields for StateName, County, and Hospital, and a Legal Values Definition dialog box with the field name 'Hospital'.
  1. If using a Legal Value or Comment Legal field for the last field, click the browse button to the right of Data Source. The Set Up Code / Legal Links dialog opens.
  2. Click Use Existing. The Open Form – Select a Table dialog box opens.
  3. Select the code table that was imported and click OK. In this example, we selected the codeHospital table.
Image showing the Set Up Code - Legal Links and the Open Form -Select a Table dialog with the table 'codeHospital' selected.
  1. Click OK. The Select a field dialog opens showing the columns in the codeHospital table that can be linked.
  2. Select the appropriate field. Because we are linking the Hospital field, we selected Hospital in this example.
Image showing the Select a Field dialog with the field 'Hospital' selected.
  1. Click OK on the Select a Field dialog. The Set Up Code / Legal Links data source table shows the values from the Hospital column in table.
Image showing the Set Up Code / Legal Links dialog with the Data Source having one column for Hospital.
  1. Click OK on the Set Up Code / Legal Links dialog box.
  2. Click OK on the field definition dialog. The next steps are to link the fields to the remaining Codes fields.
  3. Open the properties for the first Codes field added above. (Right click the field and select Properties.) Our first field was ‘StateName’ and we want to link this field to the County field so when State is selected, only the corresponding counties are shown in the County field.
  4. In the Select Fields to be Linked box, select the field you want to be filtered. Since, in our example, we want the County field to be filtered based on the selection made for State Name, we should select County here.
  5. Click the Browse button to the right of Data Source. The Codes dialog opens.
  6. Click Use Existing. The Select a Table dialog box opens.
  7. Select the same code table used to link the last field. In our example, codeHospital is the code table we are using.
  8. Click Link. The Match Fields dialog box opens. This is where we match the fields in our cascading sequence to the columns in the code table.
  9. Select the column to be linked to the first Codes field. Since our first field is State, we selected State.
  10. In the Link Associated Fields group, select the Form Field to be linked. For our example we want County to be linked to State, so we selected County.
  11. In the Table Fields drop-down, select the corresponding column in the code table.
  12. Click Link. The association to the linked field appears in the Linked Fields box.
Image showing the Match Fields dialog.
  1. Click OK to close the Match Fields dialog.
  2. Repeat the steps 12 through 22 for each remaining Codes field in the cascading sequence. For each, specify the next field in the cascading sequence and link it to the corresponding field in the code table. In our example, County is the only remaining Codes field to be linked and this field will be linked to Hospital.
Image showing the Match Fields dialog.

This completes the process to create a series of cascading drop-down fields. When the form is opened in Enter, the selection made in the first field in the cascading sequence will filter the values shown in the next field in the sequence. In our example, when Florida is selected for State Name, the list shown for County only includes the values Alchua, Baker, Escambia, and Miami-Dade.

Image showing the County codes field filtered to show only the counties for the selected State Name. When Florida is selected in the State Name field, only the counties linked to Florida are shown in the County list.

The StateName codes field filters the County codes field because of they way they are linked and because Alchua, Baker, Escambia, and Miami-Dade are the only counties on the same rows as Florida in the codeHospital table.

Image showing the codeHospital table imported from Excel.

Likewise, when the county Alchua is selected, only the values Alchua-Hosp1 and Alchua-Hosp2 are shown in the Hospital legal values field.