Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

BOOKMARKS

Posted on 2000-04-27
7
Medium Priority
?
568 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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

604 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