To reduce storage needs, frequently you might want to store short, encoded values in the database, but these encoded values might not be meaningful to users. To make reports and forms easy to use, you can define code tables.
Each row in a code table is a pair of corresponding values: a display value and a data value. The display values are those users see in a report and in a form. The data values are those that are saved in the database.
Limit on size of data value
The data value you specify for the Checkbox, DropDownListBox, Edit, EditMask, and RadioButtons edit styles is limited to 255 characters.
You can define a code table as a property of the following column edit styles:
Edit
DropDownListBox
RadioButtons
DropDownDataWindow
EditMask, using spin control
The steps to specify the code table property for each edit style are similar: you begin by defining a new edit style in the Database painter. Once you select an edit style, use the specific procedure that follows to define the code table property.
For how to create an edit style, see About edit styles.
Allowing null values
An internal InfoMaker code, NULL!, indicates null values are allowed. To use this code, specify NULL! as the data value, then specify a display format for nulls for the column.
To define a code table as a property of the Edit edit style:
-
Select the Use Code Table check box.
-
Enter the display and data values for the code table.
-
If you want to restrict input in the column to values in the code table, select the Validate check box.
For more information, see Validating user input.
To define a code table as a property of the DropDownListBox edit style:
-
Enter the display and data values for the code table.
-
If you want to restrict input in the column to values in the code table, clear the Allow Editing check box.
For more information, see Validating user input.
To define a code table as a property of the RadioButtons edit style:
-
Enter the display and data values for the code table.
To define a code table as a property of the DropDownDataWindow edit style:
-
Specify the column that provides the display values in the Display Column box.
-
Specify the column that provides the data values in the Data Column box.
-
If you want to restrict input in the column to values in the code table, clear the Allow Editing check box.
When data is retrieved into a report or form column with a code table, processing begins at the top of the data value column. If the data matches a data value, the corresponding display value displays. If there is no match, the actual value displays.
Consider the example in the following table.
If the data is MA or ma, the corresponding display value (Massachusetts) displays. If the data is Ma, there is no match, so Ma displays.
Case sensitivity
Code table processing is case sensitive.
If the code table is in a DropDownListBox edit style, and if the column has a code table that contains duplicate display values, then each value displays only once. Therefore, if this code table is defined for a column in a form that has a DropDownListBox edit style, Massachusetts and Rhode Island display in the ListBox portion of the DropDownListBox.
When users enter data into a column in a form, processing begins at the top of the display value column of the associated code table.
If the data matches a display value, the corresponding data value is put in the internal buffer. For each display value, the first data value is used. Using the sample code table, if you enter Massachusetts, ma, or Mass, the data value is MA.
You can specify that only the values in the code table are acceptable:
-
For a column using the Edit edit style, select the Validate check box.
-
For the DropDownListBox and DropDownDataWindow edit styles, clear the Allow Editing check box: users cannot type a value.
Although users cannot type a value when Allow Editing is false, they can search for a row in the drop-down list or DataWindow by typing in the initial character for the row display value. The search is case sensitive. For the DropDownDataWindow edit style, the initial character for a search cannot be an asterisk or a question mark. This restriction does not apply to the DropDownListBox edit style.
Code table data
The data values in the code table must pass validation for the column and must have the same datatype as the column.