Subject Re: [IBO] TIB_Cursor Education Needed
Author Daniel Rail
Hi,

At May 26, 2003, 17:27, kumasoftllc wrote:

> I am attempting to use tib_cursor to populate the Items and
> ItemValues of a TIB_ComboBox. Using some sample code from one of the
> Tech Info Sheets I tried the following in the FormCreate event:

> HMSDataModule.ReadOnlyTransaction.StartTransaction;
> cBox.Items.Clear;
> cBox.ItemValues.Clear;
> with myCursor do
> begin
> First;
> while not Eof do
> begin
> cBox.Items.Add(myCursor.FieldByName('myCode').AsString);
> cBox.ItemValues.Add(myCursor.FieldByName('myKey').AsString);
> Next;
> end;
> Close;
> end;
> HMSDataModule.ReadOnlyTransaction.Commit;

Try it this way:

HMSDataModule.ReadOnlyTransaction.StartTransaction;
cBox.Items.Clear;
cBox.ItemValues.Clear;
with myCursor do
begin
if not Prepared then
Prepare;
Open;
while not Eof do
begin
cBox.Items.Add(myCursor.FieldByName('myCode').AsString);
cBox.ItemValues.Add(myCursor.FieldByName('myKey').AsString);
APINext;
end;
Close;
end;
HMSDataModule.ReadOnlyTransaction.Commit;


That is how I have my code, and it works for me.

--
Best regards,
Daniel Rail
Senior System Engineer
ACCRA Group Inc. (www.accra.ca)
ACCRA Med Software Inc. (www.filopto.com)