Topic: If statement causes exe file to hang
I'm trying to fill a combobox manually as the field I need to fill it with does not have a foreign key.
The code works without the IF statement but fails on <> ''. If I put a space between the two quote marks the program will start.
The reason for the IF statement below is because I don't want the combobox filled with Null values, I only want to see (in this case) a list of purchase order numbers, so if one does not exist the combobox won't get filled with a space.
procedure frmMain_OnShow (Sender: TObject; Action: string);
var
poRef: Tdataset;
begin
try
SQLQuery('SELECT orderRef FROM orders',poRef); {read in the table Orders column OrderRef}
frmMain.cmbOrderRef.Clear; {clear the combobo contents}
while not poRef.EOF do begin
if (poRef.FieldByName('orderRef').AsString) <> ' ' then {check for no PO number in field}
begin
frmMain.cmbOrderRef.Items.Add(poRef.FieldByName('OrderRef').AsString);
poRef.next;
end;
end;
finally
poRef.close;
poRef.Free
end;
.......
.......
.......
end;
Any pointers as to what I'm doing wrong?