In this step, you will create a SearchByName method routine and add code to the SearchButton.Click event to perform a search routine based on field STD_OBJ.
The search logic will use the SELECT_SQL command to search the table xEmployee.
SELECT_SQL Command |
|---|
3. Create a method routine SearchByMonth which will complete in a later step.
4. Compile and test the form. You should be able to perform a surname search. Search beginning such as value 'Sa will find all surnames beginning Sa. A Search contains value 'ph' will find surnames such as Randolph and Shepherd. You could easily provide many more name search options.
5. Complete the SearchByMonth routine. The SQL MONTH function returns the 2 digit month portion of a date field.
Add code to perform the following:
Clear list EmployeeList
Assign STD_STRNG to SQL statement which retrieves fields Identification, Surname, Given Names and DateOfBirth from table XDEMOLIB.xEmployee where MONTH(DateofBirth) = ' + #SearchMONTH.AsString
SELECT_SQL for fields Identification, Surname and GivenNames Using STD_STRNG
Assign Fullname to surname.trim + ', ' + GivenNames.trim
Assign STD_DESCS to xEmployeeIdentification
Add each entry to EmployeeList
End Select
Your code should look like the following:
Mthroutine Name(SearchByMonth)
Clr_List Named(#EmployeeList)
#STD_STRNG := 'SELECT xEmployeeIdentification, xEmployeeSurname, xEmployeeGivenNames, xEmployeeDateOfBirth FROM XDEMOLIB.XEMPLOYEE WHERE MONTH(xemployeedateofbirth) = ' + #iiiMonth.asstring
#xEmployeeIdentification := *null
Select_Sql Fields(#xEmployeeIdentification #xEmployeeSurname #xEmployeeGivenNames) Using(#std_strng)
#iiiFullName := #xEmployeeSurname.trim + ', ' + #xEmployeeGivenNames.trim
#STD_DESCS := #xEmployeeIdentification
Add_Entry To_List(#EmployeeList)
Endselect
#xEmployeeIdentification #xEmployeeSurname #xEmployeeGivenNames := *null
Endroutine
6. Compile and test the form. You should now be able to perform a search by month and select any month to return all employees with Date of Birth containing the search month.