We help IT Professionals succeed at work.

# Problems with jumping to a specific record

on
Medium Priority
194 Views
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
Comment
Watch Question

## View Solution Only

Commented:
What you mean with Jump ?
You need read data of this record, delete or any other ?
Commented:
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;

Not the solution you were looking for? Getting a personalized solution is easy.

Commented:
Thank you ZifNab, for your excellent answer!
I really appreciate it..
Erik N

Commented:

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;

Commented:
I agree ! It´s sad, but it doesn´t really matter..
I will give you the Points for this later on...
Erik N
Access more of Experts Exchange with a free account
##### Thanks for using Experts Exchange.

Limited access with a free account allows you to:

• View three pieces of content (articles, solutions, posts, and videos)
• Ask the experts questions (counted toward content limit)
• Customize your dashboard and profile