Bookmark without moving to the record?

G

George Hester

I havve a semi-colon delimited list of numbers which correspond to a field
which is the Primary key. Say something like this:

(2;13;259;1098)

What I would like to do is save record 2's bookmark, save record 13's
bookmark and so on. But I do not want those records to become the currect
record to do this. Can we save bookmarks of records that are not the current
record? If so how? Thanks.
 
A

Albert D. Kallal

I suppose in theory you could actually save the bookmark, but do keep in
mind the book are bookmarks are a very temporary type of reference to a
record.

If you anywhere in your code requery the record set, or even load up anohter
reocrdset, the bookmarks are all invalid (there not valid between different
record sets in code).

You already have a nice list of primary keys as a way to reference those
records. You could declare separate variable(s) for each bookmark you want
to idenfity each of those reocrds. furthermore, a bookmark can only be
saved if you actually do in fact move the record first, and THEN grab the
bookmark.

To save a records bookmark, you simply declare a variable of type string,
and then you can save the current records bookmark.

eg:

dim strBookMark as string


strBookMark = me.BookMark

Normally we use bookmarks when we don't have an easy way to reference or
keep the primary key of the record in question. Since in your case you
already have the primary key (in a nice list), then you can easily reference
these records in code anyway you want.

You can go:


dim rstRecord as dao.RecordSet
dim strSql as string
dim strReocrdsList as string

strRecordList = "(2;13;259;1098)"

strReocrdList = replace(strRecordList,";",",")
strSql = "select * from tblCustomer where id in " & strReocrdList
set rstRecord = currentdb.OpenRecordSet(strSql)

Your recordset will now be loaded with the above four records. You
process/loop these records as follows:

do while rstRecord.EOF = false
debug.print rstRecord!ID
....do whatever
rstRecord.MoveNext
loop
rstRecord.Close

So, the above record set processing can be kind done completely independent
of a form's reocrdset (in fact you can run the above code and a standard
module not even have to have a form opened).

You might want to expand on why you want to convert nice ready made list of
primary keys that identify records and convert them into bookmarks? You
might have an advantage to use bookmarks, but with the information you've
given so far, I don't think you need bookmarks as a solution here.
 
G

George Hester

Yes Albert you are right. I didn't need the bookmarks at all. Thank
goodness. Yeah in theory those bookmarks are there but the only way to get
them is to make the record we want the bookmark for, the current record.
Ugh! Pretty soon I will be moving over to Access in general instead of using
its browser control. It's OK for now but I am sort of limited in what I can
do. Like for example I want to know which button was pushed on the
Navigation control and I am sure that information is in the Event but how to
access those events is really tough.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top