Step 8. Sort Department and Sections Combo Boxes (optional)
FRM055 - List Component Basics
This step demonstrates how to use the Ascending.
property of a combo box column to display departments and sections in description sequence. The column also has a a property with a default value of1. Combo box columns are automatically named CBCL_1. CBCL_2 and so on. Select the column for Department Description (field DEPTDESC) in the DEPTS combo box using either of the following methods
a. In the
view, select the tab.- Select a combo box column (CBCL_1, CBCL_2 etc) from the drop down at the top of the tab.
- Ensure that you have selected the column for field DEPTDESC (Source property)
b. Alternatively, in the
view select the tab.- Expand the combo box DEPTS
- Hover the cursor over each column (CBCL_1 and CBCL_2 in this case) and use the to discover which column is required
- Click on the column to select it.
2. With the column in the combo box DEPTS selected which contains department description (field DEPTDESC). Use the 1.
tab to change its property to
3. Find the column for combo box SECTS containing section description (SECDESC) and change its 1.
property to4. Save your changes.
5. Now that the combo box entries are sorted by their description field, you will need to change the method used to position the top entry.
a. Add the code shown in highlited (red, italic) to the form
routine. This gives the first entry in combo box DEPTS focus and retrieves the first entry. Remember the FOR loop processes the sorted list.Evtroutine Handling(#com_owner.Initialize)
Set Com(#com_owner) Caption(*component_desc)
Clr_List Named(#DEPTS)
Select Fields(#DEPTS) From_File(deptab)
Add_Entry To_List(#DEPTS)
Endselect
For Each(#item) In(#DEPTS.items)
#item.focus := true
#std_num := #item.entry
Get_Entry Number(#std_num) From_List(#DEPTS)
Leave
Endfor
Execute Subroutine(SECTS)
Endroutine
b. In the subroutine SECTS, comment out the two lines shown as commented (beginning with *) below(Hint: Use ).
c. Add the FOR logic also shown in bold. This will give focus to the first displayed entry and retrieve this entry in order to have the correct section code (field SECTION) to build the list of employees.
Subroutine Name(SECTS)
Clr_List Named(#SECTS)
Select Fields(#SECTS) From_File(sectab) With_Key(#deptment)
Add_Entry To_List(#SECTS)
Endselect
* Get_Entry Number(1) From_List(#SECTS)
* #SECTS.currentItem.focus := true
For Each(#item) In(#SECTS.items)
#item.focus := true
#std_num := #item.entry
Get_Entry Number(#std_num) From_List(#SECTS)
Leave
Endfor
Execute Subroutine(EMPLOYS)
Endroutine
6. Compile and test your new version of form iiiListBasics.
Note: Remember you may have at least one department which you added, which has no sections and no employees.