ลักษณะอย่างด้านล่างครับ แต่เงื่อนไขคือ ถ้า pttype=17 ให้แสดงข้อความที่ต้องการ
procedure GlobalOnCreate;
begin
showmessage('ÃÒ§ҹ¤èÒÃÑ¡ÉÒ¾ÂÒºÒżÙé»èǹ͡ ẺÃÒ§ҹ ¹¤.1 '+'Ẻ·Õè 1 ᡵÒÁ¡ÅØèÁÊÔ·¸Ô UC ¹Í¡à¢µ·Ñé§ËÁ´');
pttype_in :=' "74" ';
pttype_name := getsqlsubquerydata('select concat(pttype," ",name)as pttname from pttype where pttype in ('+pttype_in+') order by pttype');
showmessage('¤Ø³àÅ×Í¡ÊÔ·¸Ô = '+pttype_name);
GetDateRangeDialog(date1, date2);
ds1:=formatdatetime('yyyy-mm-dd',date1);
ds2:=formatdatetime('yyyy-mm-dd',date2);
hospcode_list:=getsqlsubquerydata('select distinct hospmain from vn_stat where pttype in('+pttype_in+') and vstdate between "'+ds1+'" and "'+ds2+'" ');
hospcode_list := getpickuplist('select concat(hospcode,":",hosptype," ",name) as name from hospcode where hospcode in ('+
hospcode_list+')order by hospcode ');
ChangeReportSQL('select v.* from vn_stat v '+
' left outer join ovst o on o.vn = v.vn '+
' where v.pttype in ('+pttype_in+') and v.vstdate between "'+ds1+'" and "'+ds2+'" '+
' and v.hospmain="'+copy(hospcode_list,1,5)+'" and o.an is null order by v.vn ');
end;