Board index » delphi » Lookup Field Updates

Lookup Field Updates


2004-06-11 07:07:58 PM
delphi112
I've defined a persistent lookup field (I'll call "DriverLookup") for a
tIBQuery (I'll call "Delivery"), and this field looks up data from another
tIBQuery (I'll call "Driver"). DriverLookup is used to assign a Driver to a
Delivery.
I let the user add new drivers when necessary. When he does, I want to
immediately update the information in the lookup field.
For example, let's say the user can not find a driver in the drop-down list of
the DriverLookup field. At this point he enters a new driver. Now, when he
looks at the drop-down list of the DriverLookup field, I'd like the new
driver to appear.
But I can not seem to make this happen. I have tried closing/opening both the
Driver query and the Delivery query, and also refreshing the dbGrid that
shows the Delivery records. I think I am handling the transactions correctly.
What am I missing?
Thanks.
 
 

Re:Lookup Field Updates

Found the answer!
There is a "RefreshLookupList" method for persistent LookUp fields. So, in
my case:
persistentLookUpFieldName.RefreshLookupList;
"Gary Mrenak" <XXXX@XXXXX.COM>writes
Quote
I've defined a persistent lookup field (I'll call "DriverLookup") for a
tIBQuery (I'll call "Delivery"), and this field looks up data from another
tIBQuery (I'll call "Driver"). DriverLookup is used to assign a Driver to
a
Delivery.

I let the user add new drivers when necessary. When he does, I want to
immediately update the information in the lookup field.

For example, let's say the user can not find a driver in the drop-down list
of
the DriverLookup field. At this point he enters a new driver. Now, when he
looks at the drop-down list of the DriverLookup field, I'd like the
new
driver to appear.

But I can not seem to make this happen. I have tried closing/opening both the
Driver query and the Delivery query, and also refreshing the dbGrid that
shows the Delivery records. I think I am handling the transactions
correctly.
What am I missing?

Thanks.


 

Re:Lookup Field Updates

See below.
"Bill Todd (TeamB)" <XXXX@XXXXX.COM>writes
Quote
Are you adding the new record in the same transaction that
DriverLookup is running in?

No, a separate transaction.
Quote
What transaction isolation level are you using?

Good question. I don't know a lot about isolation levels. To do what I want
to do (add a new Driver and have it show up in the drop-down list for the
DriverLookUp field in the Delivery dbGrid), what isolation level for the
Delivery and Driver would be appropriate?
Thanks.
Quote
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
 

Re:Lookup Field Updates

Thanks for the insight. Very helpful.
"Bill Todd (TeamB)" <XXXX@XXXXX.COM>writes
Quote
You must make sure that you commit the transaction that added the new
record before you close and reopen the query that supplies the lookup
data. You must also make sure the transaction that contains the lookup
uses read committed transaction isolation. If you use snapshot
isolation you will not be able to see any changes made by other
transactions for the life of the snapshot transaction.

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)