Solved

saving bookmark when table closes

Posted on 1998-05-19
12
177 Views
Last Modified: 2010-08-05
How can I save a bookmark when the table closes, it seems to wipe out?  I am using TBookMarkStr with D3. Thanks, tom.
 
0
Comment
Question by:tomcorcoran
  • 5
  • 4
  • 3
12 Comments
 
LVL 1

Expert Comment

by:Greedy
ID: 1346339
What database system?
0
 

Expert Comment

by:jhunt
ID: 1346340
TBookmark is a Pointer type to a internal list witch keeps track of the record youre pointing on. When you close a table and reopen it the internal list will be createted, but at a different memory location. This wil make your saved bookmarkpointer useles.
Try this:
Make sure your table has a primary unique index and save the field value from that unique index. Next time your table opens you can perform a gotokey to go to the position you have saved.
0
 

Author Comment

by:tomcorcoran
ID: 1346341
We are using paradox. Greedy, thanks for the information, I'm not sure that this method can work as the user can select the database (and chanhe the index) at run-time. Maybe I could used the Indexdef property to find the primary index fields?

Thanks, Tom.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Expert Comment

by:jhunt
ID: 1346342
Dear Tom,
In every good table design there should be 1 unique field in eacht table, mostly of the type autoincrement. My solution suggested placing code in the beforeclose event of the ttable. From every table you should know with field is the unique key field. An as the code is executed everytime for each table it should not be that difficult to save the primary key !

John
0
 
LVL 1

Expert Comment

by:Greedy
ID: 1346343
If your useing Parodox you HAVE to have a primary key for the Table.  I'm curious why you whould want to open a table then close it then open it again?
0
 

Expert Comment

by:jhunt
ID: 1346344
Dear Tom,
if you are saving from tables with unknown structures you can iterate the indexes to find out the primary key:

to find all indexes use the GetIndexNames procedure with fills the tstrings. Then you can loop thou that list and with the
Indexproperty (TStrings.Items[loopcount], idUnique) you can find the primary index.
Finally the bde function DBIGetIndexDesc can give you the the field from the primary key.

John
0
 

Author Comment

by:tomcorcoran
ID: 1346345
Allright guys. JHunt, you are describing an ideal situation which I have never seen existing in a large maintained system. It's a database utlity, the user can open any one of about 100 tables, all with primary indexes from 0 to 3 fields. To satisfy your curiousity Greedy, in order to use Tutil32 to verify/repair tables the database must be closed - so I temporarily close and then reopen but don't want to loose the record the user was on. Thanks, Tom.
0
 

Author Comment

by:tomcorcoran
ID: 1346346
PS. Greedy, you do no have to have a primary key with paradox.
0
 

Author Comment

by:tomcorcoran
ID: 1346347
Greedy, FYI, you do not have to have a primary index in paradox.
0
 
LVL 1

Expert Comment

by:Greedy
ID: 1346348
Your right...I was thinking Access, sorry.  One thing you can do with Paradox is Table1.RecNo and map that to an int and then to get back to the record do this:

  Table1.DisableControls;
  Table1.First;
  For I := 1 to MyOldPos - 1 do
    Table1.Next;
  Table1.EnableControls;

You won't be able to use it for multipul users.  But it might work for what your doing.


0
 

Author Comment

by:tomcorcoran
ID: 1346349
Greedy, that worked great, thanks a million. Please post dummy answer so I can grade.  Tom.
0
 
LVL 1

Accepted Solution

by:
Greedy earned 50 total points
ID: 1346350
No problem, glad to help...
see comments for answer.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
When I am typing into a TEdit last word repeats 7 145
Help on project with Soap 10 57
Downloading email attachments 2 79
Firemonkey BASS_Init into a thread 17 30
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question