Working with @DBColumn
The @DBColumn function can be used to dynamically populate a field with values. In other words, the options displayed in a radio button, checkbox, listbox, prompt, or other design element can be dynamically managed without having to change the design of the database.
How It Works
When using the @DBColumn function, all values from a particular view column are returned to the routine. For example, let's say you have an action item database, and one view contains a separate document for each person in the department. As each new team member arrives, a person document is created. As team members migrate to other departments or projects, their documents are removed. Using the @DBColumn function, you can dynamically assign new tasks to team members represented by person documents (see Figure 14.14).
Figure 14.14. Using @DBColumn to provide values for a checkbox field
Implementation
Step 1. |
Determine (or create) the view and column that contain the values to be utilized by the field. Make note of the view name and column number. These design elements can be hidden or displayed. If the column is not the first in the view, be sure to accurately count the column number.
|
Step 2. |
Create a field and select the field type as desired (such as radio button, combobox, checkbox, or listbox) in tab 1 of the properties dialog. In tab 2, change the Choices option to Use formula for choices and insert the following formula in the dialog box. Be sure to change the formula to include the actual view name and desired column number. Close the properties dialog when finished.
Class :=""; Cache := "NoCache"; Host := ""; Viewname := "VIEW"; Column := 1; result := @Unique(@DbColumn(Class : Cache; Host; Viewname ; Column)); @Sort (result; [Ascending]); |
Tip
Use the @Sort function to display results in ascending or descending order. An example of this function is covered later in this chapter.