Topic: Adding an entry through the ComboBox if such a value does not exist

Adding entries through the ComboBox if such a value does not exist.
For example, allows you to quickly add a client, it is not in the database.


procedure frmEmployee_bSave_OnClick (Sender: string; var Cancel: boolean);
begin
    if (frmEmployee.cbGroup.dbItemID = -1) and (frmEmployee.cbGroup.Text <> '') then
    begin
        if 6 = MessageDlg('You really want to add a new group: ' + frmEmployee.cbGroup.Text, mtConfirmation, mbYes + mbNo, 0) then
        begin
            SQLExecute('INSERT INTO groups (groupname) VALUES ("'+frmEmployee.cbGroup.Text+'")');
            UpdateDatabase('groups');
            frmEmployee.cbGroup.dbItemID := Last_Insert_id;
        end;
     end;
end;


begin
     frmEmployee.cbGroup.HideTextIfNotExists := False;
end.

Project:
http://myvisualdatabase.com/forum/misc. … download=1

Dmitry.

Re: Adding an entry through the ComboBox if such a value does not exist

thank you