I have got a TTable component that uses the BDE to access a DBase table. There is no index on the table, so the sort order is the physical order of the records in the table. If I read the RecNo property, it contains the expected number for the current record.
I was under the impression that with this constellation (BDE + DBase) it is also possible to set the RecNo property to move to the corresponding record. But apparently this does not work in my program.
So: Do I remember this incorrectly? Or is there anything special I need to do for this to work?
(Please do not advise about dropping the BDE. I am aware of its issues and we are already migrating away from it.)
TBDEDataSet
implements RecNo
setter only for Paradox
(not DBase
).
unit DBTables;
...
procedure TBDEDataSet.SetRecNo(Value: Integer);
begin
CheckBrowseMode;
if (FRecNoStatus = rnParadox) and (Value <> RecNo) then
begin
DoBeforeScroll;
if DbiSetToSeqNo(Handle, Value) = DBIERR_NONE then
begin
Resync([rmCenter]);
DoAfterScroll;
end;
end;
end;
You might want to try something generic like this:
procedure SetRecNo(DataSet: TDataSet; const RecNo: Integer);
var
ActiveRecNo, Distance: Integer;
begin
if (RecNo > 0) then
begin
ActiveRecNo := DataSet.RecNo;
if (RecNo <> ActiveRecNo) then
begin
DataSet.DisableControls;
try
Distance := RecNo - ActiveRecNo;
DataSet.MoveBy(Distance);
finally
DataSet.EnableControls;
end;
end;
end;
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With