********************************************************************** FUNCTION MyLookup(tcAlias, tcOrder, txSeekValue, tcReturnValue, tlEmptyValues) * Search in another table. This function solves certain problems with VFP-relations * (the problem is that the user only sees new values after a TableUpdate()). * The parameter tcReturnValue should be passed as a string that will be evaluated * in the function. * If the fifth parameter is .T., the function returns an empty field (rather than null) * if the record is not found. * For fast re-opening, the table is opened with a special alias, and remains open. local lnSelect, llFound, lcAlias lnSelect = select() lcAlias = tcAlias + "_mylookup" if not used(lcAlias) use (tcAlias) again alias (lcAlias) in 0 endif select (lcAlias) set order to (tcOrder) llFound = iif(isnull(txSeekValue), .F., seek(txSeekValue)) local lxReturnValue lxReturnValue = eval(tcReturnValue) && This will assign correct type, even if not found && (and final result is NULL) if not (llFound or tlEmptyValues) lxReturnValue = NULL endif select (lnSelect) return lxReturnValue ENDFUNC