Solved

BOOKMARKS

Posted on 2000-04-27
7
554 Views
Last Modified: 2008-03-10
In a form, I want to  bookmark a record, requery the form, then return to the bookmarked record.

My code is as follows:

Dim x As Variant
x = Forms![MIW_ISSUESWALL_Issue Description Entry Form].Bookmark
Forms![MIW_ISSUESWALL_Issue Description Entry Form].Requery
'MsgBox x
Forms![MIW_ISSUESWALL_Issue Description Entry Form].Bookmark = x

I am getting the error
"3159 Not a valid bookmark"

Can anyone help???

Suzanne
0
Comment
Question by:Alesso
7 Comments
 
LVL 6

Expert Comment

by:simonbennett
ID: 2755331
Have you tried

Dim x As Bookmark

....or...

Dim x As String

Good Luck

Simon
0
 
LVL 1

Author Comment

by:Alesso
ID: 2755371
Ive tried both of them,

Dim x as bookmark says bookmark isnt a valid datatype

and dim x as string gives me the same error as dim x as variant...
0
 
LVL 57
ID: 2755462
The .Requery is the problem.  All bookmarks are invalidated when a Requery is done.  All bookmarks are recreated.  You must find or seek the record based on it's key.

Jim.
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 9

Accepted Solution

by:
BrianWren earned 50 total points
ID: 2755465
Bookmarks are strings

Dim x as String...

Bookmarks are changed when the recordset changes.  If you change the data, then requery, the bookmark won't be valid, even if it exists.

You can add field to your recordset, then uniquely set that field, do your requery, then look for that unique value in the new recordset, or you can store in variables enough fields values to uniquely identify the record, then re-find it after the requery.

   Dim f as form
   Set f = Forms![MIW_ISSUESWALL_Issue Description Entry Form]

   Dim SaveID as Long
   SaveID = f!ID   ' Someething unique...
   f.Requery
   Dim r as recordset
   Set r = f.recordsetClone
   r.FindFirst "ID = " & SaveID
   f.BookMark = r.BookMark

Brian
0
 
LVL 1

Author Comment

by:Alesso
ID: 2755541
I discovered that It didnt work with the requery.

Now I have the following code:
Dim f As Form
Set f = Forms![MIW_ISSUESWALL_Issue Description Entry Form]
Dim SaveID As Integer

SaveID = f![Issue Number]  ' my keyID
f.Requery
Dim r As Recordset
Set r = f.RecordsetClone
r.FindFirst "[Issue Number] =" & SaveID

This does not work, it requerys and leaves me at the first record.... It does not bring me back to the record I was on....
0
 
LVL 1

Author Comment

by:Alesso
ID: 2755560
Wait, I left off the end
f.bookmark=r.bookmark

so the following code works:

Dim f As Form
Set f = Forms![MIW_ISSUESWALL_Issue Description Entry Form]
Dim SaveID As Integer
SaveID = f![Issue Number]  ' my keyID
f.Requery
Dim r As Recordset
Set r = f.RecordsetClone
r.FindFirst "[Issue Number] =" & SaveID
f.bookmark=r.bookmark


Thank you!!
0
 
LVL 9

Expert Comment

by:BrianWren
ID: 2755575
You can click the button above the comment you like as an answer that says, "Select Comment as Answer", then grade the answer.  Higher grades gives the 'expert' more points, same cost to you.  (Shameless plug, I know...)

Brian
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now