Step 5. Populate the Tab Sheets

In this step, you will create an ItemGotSelection event routine for the employees list view, and fetch employee data and select the notes data.

1.  At the top of the Source, define a Group_By for the fields shown on the application's Details tab sheet.

Group_By Name(#Details) Fields(#xEmployeeIdentification #xEmployeeTitle #xEmployeeSurname #xEmployeeGivenNames #xEmployeeStreet #xEmployeeCity #xEmployeeState #xEmployeePostalCode)

2.  Switch to the Design tab. Select the employees list view. On the Details/Events tab double click on ItemGotSelection to create an event routine.

3.  Complete the ListView1.ItemGotSelection event routine based on the following:

Assign xEmployeeIdentification to STD_OBJ  

Fetch fields Details from the table xEmployee with the key xEmployeeIdentification

Clear the list EmployNotes

Select field xEmployeeNote from the index xEmployeeNotesByEmployee with the key xEmployeeIdentification

  Add entry to EmployNotes

End select

     Your code should look like the following:

Evtroutine Handling(#ListView1.ItemGotSelection) Options(*NOCLEARMESSAGES *NOCLEARERRORS)

#xEmployeeIdentification := #STD_OBJ

Fetch Fields(#details) From_File(xEmployee) With_Key(#xEmployeeIdentification)

Clr_List Named(#EmployNotes)

Select Fields(#xEmployeeNote) From_File(xEmployeeNotesByEmployee) With_Key(#xEmployeeIdentification)

Add_Entry To_List(#EmployNotes)

Endselect

Endroutine
 

4.  Add code to the end of the SEARCH.Click event to clear the employee fields using the Group_By Details and clearing the EmployNotes list. Your code should look like:

. . . . .

Endselect

#Details := *default

Clr_List #EmployNotes

Endroutine
 

5.  Test your completed application. You should be able to search by one of three methods. Changing focus to an entry in the employees list view should display employee details and populate the EmployNotes list view.