Subject IBOQuery and TDBLookupComboBox
Author paultugwell
I have converted an application from BDE to IBO and am having a
problem with getting the data in a TDBLookupComboBox to track the
data in the undelying query.

3 IB tables are involved
SalesItems (SI), Categories (C) and SubCategories (S)

SI contains fields CAT and SUBCAT (and other fields) which are
populated by selecting values linked to the tables C and S

Table C contains a field CAT (and other fields) and table S contains
fields CAT and SUBCAT (and other fields).

There are 2 IBOQueries
SELECT CAT FROM CATEGORIES
and
SELECT CAT, SUBCAT FROM SUBCATEGORIES WHERE CAT = :CAT
This query is linked to the first query by a TDataSource component.

Both queries are selecting the correct information.
When moving through the a query based on SI, the values of SI.CAT and
SI.SUBCAT change. When SI.CAT changes, the TDBLookupComboBox linked
to the SI.CAT field updates correctly but the TDBLookupComboBox
linked to the SI.SUBCAT does not even though the correct values are
fetched by the query.
Sometimes the value displayed is correct but at other times (more
commonly) the value displayed is blank. It is even possible to scroll
forward through a record and the value to display correctly and the
scroll back from the following record and the value to display as a
blank.

I placed an IB_Monitor component on the offending form and obtained
the following output when scrolling from one record to the next. It
is clear from this that the problem has been caused by the order of
the SQL statements. The change in SI cause a change in SI.CAT
from 'ZINTEC O/S' to 'ALUMINISED' and a change in SI.SUBCAT from NULL
to 'AS04'. However the subcategories table is queried to locate the
SUBCAT before the subcategories IBOQuery is updated, resulting in the
error. In the BDE version of this program there is no such problem!
Can you help me?


/*---
PREPARE STATEMENT
TR_HANDLE = 16040924
STMT_HANDLE = 35095268

SELECT SUBCATEGORIES.CAT, SUBCATEGORIES.SUBCAT
FROM SUBCATEGORIES
WHERE (
CAT = ? /* CAT */
)
AND (((SUBCAT = ? /* LOC_1_SUBCATEGORIES_SUBCAT */ )))

PLAN (SUBCATEGORIES INDEX (RDB$PRIMARY26))

FIELDS = [ Version 1 SQLd 2 SQLn 30
SUBCATEGORIES.CAT = <NIL>
SUBCATEGORIES.SUBCAT = <NIL> ]

SECONDS = 0.011
----*/
/*===
//>>> STATEMENT PREPARED <<<//
TIB_Statement.API_Prepare()
TIB_LocateCursor: "IBOqrqySubList." stHandle=35095268
====*/
/*---
EXECUTE STATEMENT
TR_HANDLE = 16040924
STMT_HANDLE = 35095268
PARAMS = [ Version 1 SQLd 2 SQLn 2
[CAT] = 'ZINTEC O/S'
[LOC_1_SUBCATEGORIES_SUBCAT] = 'AS04' ]

SECONDS = 0.010
----*/
/*---
FETCH
STMT_HANDLE = 35095268
FIELDS = [ Version 1 SQLd 2 SQLn 2
SUBCATEGORIES.CAT = <n> ''
SUBCATEGORIES.SUBCAT = <n> '' ]

ERRCODE = 100
----*/
/*---
EXECUTE STATEMENT
TR_HANDLE = 16040924
STMT_HANDLE = 16025404
PARAMS = [ Version 1 SQLd 1 SQLn 1
[CAT] = 'ALUMINISED' ]

SECONDS = 0.010
----*/
/*---
FETCH
STMT_HANDLE = 16025404
FIELDS = [ Version 1 SQLd 2 SQLn 2
SUBCATEGORIES.CAT = 'ALUMINISED'
SUBCATEGORIES.SUBCAT = 'AS03' ]
----*/
/*---
FETCH
STMT_HANDLE = 16025404
FIELDS = [ Version 1 SQLd 2 SQLn 2
SUBCATEGORIES.CAT = 'ALUMINISED'
SUBCATEGORIES.SUBCAT = 'AS05' ]
----*/
/*---
FETCH
STMT_HANDLE = 16025404
FIELDS = [ Version 1 SQLd 2 SQLn 2
SUBCATEGORIES.CAT = 'ALUMINISED'
SUBCATEGORIES.SUBCAT = 'ASO1' ]
----*/
/*---
FETCH
STMT_HANDLE = 16025404
FIELDS = [ Version 1 SQLd 2 SQLn 2
SUBCATEGORIES.CAT = 'ALUMINISED'
SUBCATEGORIES.SUBCAT = 'ASO2' ]
----*/
/*---
FETCH
STMT_HANDLE = 16025404
FIELDS = [ Version 1 SQLd 2 SQLn 2
SUBCATEGORIES.CAT = 'ALUMINISED'
SUBCATEGORIES.SUBCAT = 'AS04' ]
----*/
/*---
FETCH
STMT_HANDLE = 16025404
FIELDS = [ Version 1 SQLd 2 SQLn 2
SUBCATEGORIES.CAT = 'ALUMINISED'
SUBCATEGORIES.SUBCAT = 'AS04' ]

ERRCODE = 100
----*/