Hi Can anyone help please, I've tried everything and exhausted my Google searching.
I have the following code. The problem lies with the
The general operation is, when the user enters some text which isn't in the dropdown and the user wants to add it, it is detected and a form opens to get other information. If information is entered then all is OK, but if the user presses Cancel I want to put the dropdown back to the original value.
This is the problem, if I hard code it to a value (say 3) then it works, but if I try to set it to the OldKeyValue (which does contains the right value) it just ignores it and the dropdown goes back to somewhere in the list related to the text that was entered (but obviously not the exact text as this wasn't in the list)
OldKeyVaue is declared as a Variant as is KeyValue in the TRxDBLookupCombo.
The exampl ebelow shows both setting because I thought it might work if I force it to a 3 then to the real value I want, but it just stays at 3 even though OldKeyValue is 22.
PS OldKeyValue is set when it enteres the DropDown.
Anyone with any thoughts, please
procedure TForm1.RxDBLookupComboClosePopup(Sender: TObject; SearchResult: boolean);
begin
with TRxDBLookupCombo(Sender) do
if (Caption <> '') and (LookupSource.DataSet.lookup(LookupDisplay,Caption,'ID') = Null) then
if Application.MessageBox (PChar('Please confirm to add ' + Caption), PChar('New ' + DataField), MB_ICONQUESTION or MB_YESNO) = IDYES then
case name of
'RxDBLookupCombo1', 'RxDBLookupCombo5':
begin
Form2.Edit3.Caption := Caption;
AddAirport (Sender);
KeyValue := 3;
KeyValue := OldKeyValue;
end;