I do it with a single text variable, vEntry, and use separate buttons for each type of lookup. Each button has an on-click EEP that attempts to convert the text to the appropriate datatype and then creates the WHERE clause and tests for the existence of that row. If they enter 103009 and mean to lookup a date but click the customer (integer) button, they merely get an error message saying the customer number wasn't found. Focus is set to the vEntry field and the original entry is not cleared, so all they have to do is click the date button without retyping anything. It saves trying to program for every permutation of valid and invalid entry for every datatype expected.

e.g.:
Partial On-Click EEP for Lookup by text part number:
SET VAR vPartNo text = (.vEntry)
-- build WHERE caluse
SET VAR vWheClause = ('PartNo = .vPartNo')

--Test to see if this part # exists
SELECT COUNT(PartNo) +
INTO vCount INDICATOR vInd1 +
FROM PartTable +
WHERE &vWheClause

IF vCount = 0 THEN
 -- If it doesn't exist
 SET VAR vMsg = (.vEntry & 'is not a valid Part number.')
 RECALC VARIABLES
 PROPERTY cidvEntry SET_FOCUS 'TRUE'
ELSE
  EDIT USING EditPart WHERE &vWheClause
ENDIF

Partial On-Click EEP for for integer customer number:
SET VAR vCustNo INTEGER = 0
SET VAR vCustNo = (NINT(.vEntry))
--IF vEntry could NOT be converted TO INTEGER
IF vCustNo IS NULL  +
  OR vCustNo = 0 THEN  -- Probably contains alpha, can't conv to Inte
 SET VAR vMsg = (.vEntry & 'is not a valid Customer number.')
 GOTO Done
ELSE
 --BUILD WHERE caluse
 SET VAR vWheClause = ('CustNo = .vCustNo')
 --Test to see if this Cust # exists
 SELECT COUNT(CustNo) +
  INTO vCount INDICATOR vInd1 +
    FROM Customer  +
    WHERE &vWheClause
 IF vCount = 0 THEN
   SET VAR vMsg = (.vEntry & 'was not found')
   RECALC VARIABLES
 ELSE
   EDIT USING CustMaint WHERE &vWheClause
 ENDIF
ENDIF

Doug

mjsmd wrote:
Hi all,
I want my user to be able to have the option of entering a birthday, last name, client ID (an integer less than 999999) or a phone number (a number greater than 1000000) in order to select the desired client. What is the best way to determine the type of data that was entered? Is there a funtion that returns the data type?



Reply via email to