Auto-Fill on Lookup_Selecting Function

How to auto-fill on the Lookup_Selecting function?// Lookup Selecting event
function Lookup_Selecting($fld, &$filter) {
//var_dump($fld->Name, $fld->Lookup, $filter); // Uncomment to view the filter
// Enter your code here
if(IsLoggedIn()){

if (!$this->isCopy() && $fld->Name == "myfield") {
	$cat= " AND cat= ".@$_SESSION["catid"];
	$fld->Lookup->UserSelect = "SELECT 'code' AS lf, CONCAT(code, ' ', elm) AS df FROM `t_elm` WHERE plc = 0 ".$cat." ORDER BY `code` ASC";
}

}

}

If you just want to check the SQL for AutoFill, you may check if Post(“ajax”) == “autofill”.