Recent

Author Topic: RxDBConvoLookup question  (Read 1108 times)

daveinhull

  • Full Member
  • ***
  • Posts: 249
  • 1 divided by nothing must still be 1!
RxDBConvoLookup question
« on: February 06, 2019, 08:15:20 pm »
Hi

I have an RxDBCombiLookup control connected to a field in a grid. When I enter that field the lookup gets focus with the value in field and I can select another value from the dropdown and it gets put into the field, all that works as expected.
However if the value of the field is null,  the combo gets null ok. I have trapped not found entered values and opened a form to get all the other data I need and if confirmed I can add the new value to the dropdown and then to the associated field, and that works.
But if I want to cancel the new value and put the dropdown back to the original value of null, it doesn't like me trying to set the .value field in the dropdown to null. It says it cant convert a null to a string, but the field is actually declared as a variant, and it does pick up nulls from the underlying grid field if it is that value.

Is there anyway to revert an RxDBComboLookup back to its entered value?

Thanks in advance
Dave
Version #:1.8.4 Date 2019-01-08 FPC Version: 3.0.4 and SVN Revision 57972 for x86_64-win64-win32/win64

daveinhull

  • Full Member
  • ***
  • Posts: 249
  • 1 divided by nothing must still be 1!
Re: RxDBConvoLookup question
« Reply #1 on: February 10, 2019, 12:19:49 pm »
Hi Can anyone help please, I've tried everything and exhausted my Google searching.

I have the following code. The problem lies with the
Code: Pascal  [Select]
  1. KeyValue := OldKeyValue

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 :(

Code: Pascal  [Select]
  1. procedure TForm1.RxDBLookupComboClosePopup(Sender: TObject; SearchResult: boolean);
  2. begin
  3.   with TRxDBLookupCombo(Sender) do
  4.   if (Caption <> '') and (LookupSource.DataSet.lookup(LookupDisplay,Caption,'ID') = Null) then
  5.     if Application.MessageBox (PChar('Please confirm to add ' + Caption), PChar('New ' + DataField), MB_ICONQUESTION or MB_YESNO) = IDYES then
  6.     case name of
  7.       'RxDBLookupCombo1', 'RxDBLookupCombo5':
  8.       begin
  9.         Form2.Edit3.Caption := Caption;
  10.         AddAirport (Sender);
  11.         KeyValue := 3;
  12.         KeyValue := OldKeyValue;
  13.       end;
« Last Edit: February 10, 2019, 12:23:00 pm by daveinhull »
Version #:1.8.4 Date 2019-01-08 FPC Version: 3.0.4 and SVN Revision 57972 for x86_64-win64-win32/win64

madref

  • Hero Member
  • *****
  • Posts: 635
  • ..... A day not Laughed is a day not Lived !!
    • Nursing With Humour
Re: RxDBConvoLookup question
« Reply #2 on: February 11, 2019, 12:54:54 pm »
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.


I presume that the data from the combobox comes from a database.
If user pressed cancel just refill the combobox with your original database query and all is restored
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 2.0.0 / FPC 3.0.4
Lazarus Trunc / FPC 3.0.4
Mac OS X Mojave

daveinhull

  • Full Member
  • ***
  • Posts: 249
  • 1 divided by nothing must still be 1!
Re: RxDBConvoLookup question
« Reply #3 on: February 11, 2019, 06:15:39 pm »
Hi madref,

Thanks for the feedback.
It is an RxDBLookupCombo with an attached datasource back to the main DB.
I have tried everything including refreshing the dataset, setting the LookupCombo index, value, caption to the value I need, but as I mentioned, if the value is the same as the original one it just ignores it, but if I force it to a different item in the dropdown it does it.

I'm almost at the point of just switching of that feature!

Dave
Version #:1.8.4 Date 2019-01-08 FPC Version: 3.0.4 and SVN Revision 57972 for x86_64-win64-win32/win64

GetMem

  • Hero Member
  • *****
  • Posts: 3431
Re: RxDBConvoLookup question
« Reply #4 on: February 11, 2019, 08:09:07 pm »
I never worked with Rx component, but what is that "UnfindedValue" property? Maybe setting to rxufLastSuccessful or rxufOriginal helps? Or maybe you found a bug and you should report it(https://sourceforge.net/p/lazarus-ccr/bugs/).

daveinhull

  • Full Member
  • ***
  • Posts: 249
  • 1 divided by nothing must still be 1!
Re: RxDBConvoLookup question
« Reply #5 on: February 11, 2019, 08:22:04 pm »
Hi GetMem,

Thanks for the reply, already tried all those combinations  %)

Beginning to think it must be a bug, but do you think anyone is still maintaining this package?

Dave
Version #:1.8.4 Date 2019-01-08 FPC Version: 3.0.4 and SVN Revision 57972 for x86_64-win64-win32/win64

GetMem

  • Hero Member
  • *****
  • Posts: 3431
Re: RxDBConvoLookup question
« Reply #6 on: February 11, 2019, 08:25:21 pm »
Hi GetMem,

Thanks for the reply, already tried all those combinations  %)

Beginning to think it must be a bug, but do you think anyone is still maintaining this package?

Dave
AFAIK user alexs75(http://forum.lazarus.freepascal.org/index.php?action=profile;u=39260) maintains package rx. Please PM him.

daveinhull

  • Full Member
  • ***
  • Posts: 249
  • 1 divided by nothing must still be 1!
Re: RxDBConvoLookup question
« Reply #7 on: February 11, 2019, 08:41:24 pm »
Thanks GetMem
Version #:1.8.4 Date 2019-01-08 FPC Version: 3.0.4 and SVN Revision 57972 for x86_64-win64-win32/win64