Topic: How to display combobox original content when using scripts?
Hi MVDB fans,
I have very specific comboboxes where I filter the information to be listed using sql scripts but as soon as I release the list without changing anything, the default content of the combo does not come back. There is no problem when I change the value though.
What should I use to get the current value of the combo when I do not change anything?
below the details:
Form: Details
Combobox : ComboSimNr
foreignkey: Users.id_SIM
fieldname : SIMNo
Scripts:
var
sim: string;
SIMsstus: string;
// Auto-update id_status on change if current status is "In Stock"
procedure Details_ComboSimNr_OnChange (Sender: string);
begin
SIMsstus:= SQLExecute('select id_status from SIM where SIM.id=' +sim);
if SIMsstus = '3'
then SQLExecute('update SIM set id_status=2 where SIM.id=' +sim);
end;
// procedure to display available numbers only when deployed or display current record by default
// SIM
procedure PopulateSIM_ComboBox(ComboBox: TdbComboBox; ShowNotUsed: boolean);
begin
if ShowNotUsed then
ComboBox.dbSQLExecute('SELECT SIMNo,'+
'id FROM SIM GROUP BY SIMNo '+
'HAVING (SELECT COUNT(*) FROM Users WHERE Users.id_SIM=SIM.id) = 0')
else
ComboBox.dbSQLExecute('SELECT SIMNo, id FROM SIM');
end;
//Populate filtered SIM Numbers in comboboxes
procedure Details_ComboSimNr_OnDropDown (Sender: string);
begin
PopulateSIM_ComboBox(Details.ComboSimNr, True);
end;
// Reset Comboboxes on Details closure
procedure Details_OnClose (Sender: string; Action: string);
begin
PopulateSIM_ComboBox(Details.ComboSimNr, False);
PopulateVodanum_Combobox(Details.ComboBox_Vodanum, False);
PopulateIMEI_Combobox(Details.ComboIMEI, False);
Form1.Show;
end;
Edit: The post not being popular, I added a picture