• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 181
  • Last Modified:

Problems with jumping to a specific record

Hi!!
I have some problems finding a procedure with wich you can jump to a specific record-number in a table, like this:

DM1.Table1.XXXX[5];
(Where I want to jump to record number five..)

I looked at GotoKey, Find and the rest of them, however they all need information other than just the record-number.

I use Delphi Developer 2.0 and the table is a Paradox-base.

Thanx!
Erik N
0
Erik N
Asked:
Erik N
  • 2
  • 2
1 Solution
 
mirek071497Commented:
What you mean with Jump ?
You need read data of this record, delete or any other ?
0
 
ZifNabCommented:
Hi Erik N,

There exists a procedure MoveBy(Distance: integer) :

The MoveBy method moves the dataset cursor by Distance records. If Distance is negative, the move is backward. If Distance is positive, the movement is forward. If Distance is zero, no move is done. MoveBy returns the number of records that were traversed.

You can use this procedure to go to the fifth record in a table.
Do it like this :

DM1.Table1.First; { Go to the first record }
DM1.Table1.MoveBy(+5); { Go to the fifth record }

So, make a function :

function MoveTo(RecordPos: Integer):Integer;
begin
 with DM1.Table1 do begin
  First;
  Result := MoveBy(RecordPos);
 end;
end;

If you need it to work on different tables :

function MoveTo(OnTable:TTable;RecordPos:integer):integer;
begin
 with OnTable do begin
  First;
  Result := MoveBy(RecordPos);
 end;
end;
 
OffCourse you better improve these functions with error checking!

Have fun,
c.u. ZifNab;

Questions, just ask!
0
 
Erik NAuthor Commented:
Thank you ZifNab, for your excellent answer!
I really appreciate it..
Erik N
0
 
ZifNabCommented:
Glad I could help you,

Does it works like you wanted it?
Sad that you always have to go to the first record isn't it?

Have fun,
c.u. ZifNab;
0
 
Erik NAuthor Commented:
I agree ! It´s sad, but it doesn´t really matter..
I will give you the Points for this later on...
Erik N
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now