Board index » delphi » Field Index Out of Range when trying to re-open a table with a different index

Field Index Out of Range when trying to re-open a table with a different index

I have a table like the following...

Key1 (Int)
Key2 (Int)
Key3 (Int)
Text (Alpha)

Keys 1 and 2 link to a master table. There is a secondary index on the
Text field.

When the following code runs...

With Data.Table_tbl do
 begin
 Close;
 IndexName:='Secondary';
 Open;

I immediately get a 'Field Index Out of Range' error. Is it something
to do with the fact that it's a child table ?

Help !

Steve Tanner

steve.tanner@(nospam)itu.int

 

Re:Field Index Out of Range when trying to re-open a table with a different index


Yes, after the child table is opened it tries to locate the master fields
using the index. If you change the index the locate will fail (the error
message is a result of the fact that is tries to do a locate with 2 master
fields on an index with 1 field).

"Steve Tanner" <stevetanne...@hotmail.com> schreef in bericht
news:7e5163a4.0106270724.297ca756@posting.google.com...

Quote
> I have a table like the following...

> Key1 (Int)
> Key2 (Int)
> Key3 (Int)
> Text (Alpha)

> Keys 1 and 2 link to a master table. There is a secondary index on the
> Text field.

> When the following code runs...

> With Data.Table_tbl do
>  begin
>  Close;
>  IndexName:='Secondary';
>  Open;

> I immediately get a 'Field Index Out of Range' error. Is it something
> to do with the fact that it's a child table ?

> Help !

> Steve Tanner

> steve.tanner@(nospam)itu.int

Re:Field Index Out of Range when trying to re-open a table with a different index


Quote
"M.H. Avegaart" <avega...@NOSPAMmccomm.nl> wrote in message <news:9hejpm$e4n$1@scavenger.euro.net>...
> Yes, after the child table is opened it tries to locate the master fields
> using the index. If you change the index the locate will fail (the error
> message is a result of the fact that is tries to do a locate with 2 master
> fields on an index with 1 field).

Thanks for your reply - this had been driving me crazy. Although I
don't quite understand why it needs to use the index for the key
lookup when this is defined elsewhere. It seems a little crazy that
unless I'm missing something obvious there's no simple of way of
searching on a non-key field of a child table without resorting to
SQL.

...And there was me thinking I was becoming a good Delphi programmer
:(

Thanks again.

Steve

Re:Field Index Out of Range when trying to re-open a table with a different index


If you need to look in the child table using other indexes, try using it
through another connection. You can create a second datasource/dataset that
uses only the child table. Moves in this dataconnection will be independent
of moves caused by browsing in the mastertable. When you've located a record
you need through the alphabetical index on the second dataset, you can read
the keyvalues and use this information to reposition in the mastertable.

--

Alex Haerens
AHA-design

alexhaerens _at_ hotmail _dot_ com

Steve Tanner <stevetanne...@hotmail.com> schreef in berichtnieuws
7e5163a4.0106270724.297ca...@posting.google.com...
| I have a table like the following...
|
| Key1 (Int)
| Key2 (Int)
| Key3 (Int)
| Text (Alpha)
|
| Keys 1 and 2 link to a master table. There is a secondary index on the
| Text field.
|
| When the following code runs...
|
| With Data.Table_tbl do
|  begin
|  Close;
|  IndexName:='Secondary';
|  Open;
|
| I immediately get a 'Field Index Out of Range' error. Is it something
| to do with the fact that it's a child table ?
|
| Help !
|
| Steve Tanner
|
| steve.tanner@(nospam)itu.int

Other Threads