Subject Re: [IBO] Lookup Doesn't work properly
Author Helen Borrie
Hello Jay,

At 04:42 PM 13/07/2005 -0500, you wrote:
>I have uploaded the sample application, database and images of the problem I
>am having (Lookup_Err_Sample.zip).

OK, I had a play with your sample app. It will probably be easiest to go
through your readme.txt and discuss each issue....

The sample shows the problematic behaviour I am having with the lookup
combo. I am currently using Delphi 7 with IB Objects 4.5.Ai. The included
images are screenshots of the behaviour I am having.

The grid that is having the problem is the on on the "Productos page".

The general idea of the program is to be able to specify the products that
are valid for a given supplier. The program is for editing the supplier and
to be able to consult and modify the products that are allowed to be
purchased from the specified supplier.

The behaviour I am getting is the following:

1) The PROVART grid display the code CVEART and the description NOMPROD
correctly.

Yes. Although I had to comment out your uses of the Jedi VCL controls as I
don't have them installed.

2) When I click on the NOMPROD field on the grid, the lookup (arrow) button
appears and the field contents become <blank>, (blue) no text.

Yes, that is as expected. The normal use of this control is to supply a
lookup value. As soon as you click the control, the record goes into Edit
mode and prepares to receive the new value. The value that is displayed in
Browse mode is, of course, a derived field so, as soon as the record is in
Edit mode (and the key value is going to change) that derived field becomes
invalid.

A valid value will appear again *after* the change is committed. At that
point, the dataset will requery the dataset and get the new value into the
derived field.

This makes this a not-very-pretty interface to implement what you are
implementing, which is not a lookup, but a master-detail
relationship. (The so-called "lookup table" is *really* a master to the
intersection set/table PROVART!)

3) I click on the arrow button and a grid of the lookup table appears with
the values of the code (CLV_ART) and the escription (DESCR), but at the
beginning of the table and not at the current value of the PROVART table.

Yes. That seemed to be due to your custom popup. To fix this, I did the
following:

i) set the productos grid temporarily to alNone and made some room beside it.
ii) deleted your ib_lookupcombo (cbArt).
iii) clicked into the spare space created beside the grid and dropped a
fresh ib_lookupcombo into it, naming it cbArt, as before
iv) set the datasource property
v) Cut (Ctrl-C) the ib_lookupcombo out of the spare space, clicked on the
grid, and then pasted (Ctrl-V) the ib_lookupcombo into the grid
vi) Then set the grid's alignment back to alClient.

Another quirk is that the first time that I open the lookup grid, it
appears very narrow. If I close it and open it again, it appears with the
correct width but still not at the value of the data.

Again, this quirky behaviour was caused by your custom popup. The fresh
ib_lookupcombo responded properly to the FieldsDisplayWidth property that
was set in the field properties.

I didn't attempt to fix your custom popup. It didn't seem to do anything
desirable so it wasn't worth wasting my time on it.

I have dedicated HOURS at this and cannot get it to work right. What am I
doing wrong?

Some things I would recommend --

a) Pay attention to your connection and transaction properties. You had a
mish-mash there which appeared to be starting default transactions. I
don't know what you intended for ib_trans, but I would have selected it as
the DefaultTransaction for the connection. Also, you had some
discrepancies that seemed to have been caused by hard-setting the
DatabasePath properties around the place, instead of using (selecting) the
IB_Connection property.

b) Maybe I'd want to rethink the UI for those two master-detail
relationships, since the embedded lookupcombo is (at least in my opinion)
quite ugly for this task and it's not immediately obvious how it works.

You have an associated problem here, that some of the descriptions are
actually blank. Again, this is manageable in a more conventional
master-detail interface but quite unfriendly to the user in this
lookup-style interface.

c) As the demo currently stands, you can't create new PROVART records
because you haven't taken care of defaulting the non-nullable column
CANTPEND. You either need to bring it into the dataset and apply a default
to it via FieldsDefaultValues, or fix the metadata so that a default gets
written one way or another.

d) I strongly recommend that you restrict the PROV01 set for displaying it
in a grid.. It is plainly ridiculous to do select * from PROV01 and have
to manage 40 columns in a grid on a page control. If you want to edit
these records, show a few identifying fields in the grid and provide a
single-row edit layout alongside, using a shared datasource for the grid,
the edit fields and the bar controls.

Helen