Subject | Locate() not working correctly |
---|---|
Author | Joe Martinez |
Post date | 2004-01-28T08:15:24Z |
I have the following piece of code:
TLocateOptions Opts;
Opts.Clear();
Variant locvalues[3];
locvalues[0] = Variant(theClassID);
locvalues[1] = Variant(theSectID);
locvalues[2] = Variant(theEnrollID);
SectEnrollsTable->Refresh();
bool LocateResult =
SectEnrollsTable->Locate("CLASSID;SECTIONID;ENROLLID",
VarArrayOf(locvalues, 2), Opts);
long NewKey = SectEnrollsTable->FieldByName("enrollid")->AsInteger;
Note: SectEnrollsTable is a TIBOTable
I was having problems where this code would often locate the wrong record,
so I traced the execution of the code in the debugger (BCB4).
Right before this block of code, theEnrollID has a value of 13975. So,
that should be the key that it's looking for.
The Locate() call (2nd to last line) returns True.
After executing the last line, NewKey has a value of 3775, NOT 13975.
How is this possible? If the Locate() on 13975 is successful, then how can
it immediately after be on a different record?
Help!
-Joe
TLocateOptions Opts;
Opts.Clear();
Variant locvalues[3];
locvalues[0] = Variant(theClassID);
locvalues[1] = Variant(theSectID);
locvalues[2] = Variant(theEnrollID);
SectEnrollsTable->Refresh();
bool LocateResult =
SectEnrollsTable->Locate("CLASSID;SECTIONID;ENROLLID",
VarArrayOf(locvalues, 2), Opts);
long NewKey = SectEnrollsTable->FieldByName("enrollid")->AsInteger;
Note: SectEnrollsTable is a TIBOTable
I was having problems where this code would often locate the wrong record,
so I traced the execution of the code in the debugger (BCB4).
Right before this block of code, theEnrollID has a value of 13975. So,
that should be the key that it's looking for.
The Locate() call (2nd to last line) returns True.
After executing the last line, NewKey has a value of 3775, NOT 13975.
How is this possible? If the Locate() on 13975 is successful, then how can
it immediately after be on a different record?
Help!
-Joe