Topic: [SOLVED] How to copy text from combobox to another form
I'm wanting to select an item in a combobox, then click on an 'edit' button which will open up a second form with the edit box filled in with the text of the item selected in the combobox. Subsequently that item will be edited and then saved back to the database.
I've tried the code below, but that is using the 'item ID' in the database which is not in the same order as the combobox.
It works, but displays the wrong item in the edit box, which of course means the wrong item gets edited and updated back in the database.
Should I change this to a SQL statement ?
procedure frmMain_btnEditSupplier_OnClick (Sender: TObject; var Cancel: boolean);
var
RecordID:integer;
begin
RecordID := frmMain.combobox2.ItemIndex; //get item number from combobox list
// check item ID for debugging
showMessage('item no ' + intToStr(RecordID));
//ShowRecord(frmEdit.,'supplier',frmMain.ComboBox2.ItemIndex );
ShowRecord(frmEdit,'supplier',RecordID ); // Open edtForm with item selected ready to be edited and saved back into database.
end;