Solved

BOOKMARKS

Posted on 2000-04-27
7
555 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Alter an update query which rounds 7 33
Storing Combo Box Selection in Table 12 45
Getting Run-Time Error 13 - Type Mismatch 3 28
access 7 26
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server functions 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 Ac…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now