Save current position in UniTable

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
testpresta
Posts: 32
Joined: Sat 07 Jun 2014 19:41

Save current position in UniTable

Post by testpresta » Sat 07 Jun 2014 19:57

Hello

I want to call Locate method on a TUniTable component in order to search a particular record.
Then i want to go back to the previous record.
How should i do ?
There is no « current position » property on TUniTable. I saw an « active record » property in source code but this property is not accessible.

I am working on Delphi

Thanks for your answer

testpresta
Posts: 32
Joined: Sat 07 Jun 2014 19:41

Re: Save current position in UniTable

Post by testpresta » Sun 08 Jun 2014 18:23

Just a remark. I noticed there is a recno property but this property is not correct when the UniTable is sorted.
The numbers are re-affected...

Thanks

CristianP
Posts: 79
Joined: Fri 07 Dec 2012 07:44
Location: Timișoara, Romania

Re: Save current position in UniTable

Post by CristianP » Tue 10 Jun 2014 08:47

Hello,

You can use GetBookmark, GotoBookmark, and FreeBookmark.

Best Regards,
Cristian Peta

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Save current position in UniTable

Post by AlexP » Tue 10 Jun 2014 09:04

Hello,

For this, you can save the value of the key field for the current record, and after all operations return to the required record using the Locate method:

Code: Select all

var
  empno: integer;
begin
  UniTable1.SQL.Text := 'SELECT * FROM EMP';
  UniTable1.OrderFields := 'ENAME ASC';
  UniTable1.KeyFields := 'EMPNO';
  UniTable1.Open;
  empno := UniTable1.FieldByName('empno').AsInteger;
  UniTable1.LocateEx('EMPNO', 7788, []);
  UniTable1.OrderFields := 'ENAME DESC';
  UniTable1.LocateEx('empno', empno, []);
end;

testpresta
Posts: 32
Joined: Sat 07 Jun 2014 19:41

Re: Save current position in UniTable

Post by testpresta » Tue 10 Jun 2014 18:27

Thanks for your answers.

Bookmarks are the same than Recno. If i order by the table it gives a mistake...

Working with primary key is a good idea but i want to do something generic for several UniTables objects.

Thanks

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Save current position in UniTable

Post by AlexP » Wed 11 Jun 2014 08:29

We plan to improve work with Bookmark, in order to avoid such situations. However, we cannot tell the exact terms of implementation of this feature.

Post Reply