Link to home
Create AccountLog in
Avatar of Alesso
Alesso

asked on

BOOKMARKS

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
Avatar of simonbennett
simonbennett

Have you tried

Dim x As Bookmark

....or...

Dim x As String

Good Luck

Simon
Avatar of Alesso

ASKER

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...
Avatar of Jim Dettman (EE MVE)
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.
ASKER CERTIFIED SOLUTION
Avatar of BrianWren
BrianWren

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Alesso

ASKER

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....
Avatar of Alesso

ASKER

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!!
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