?
Solved

BOOKMARKS

Posted on 2000-04-27
7
Medium Priority
?
562 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 58
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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 9

Accepted Solution

by:
BrianWren earned 200 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

771 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