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_Issu e Description Entry Form].Bookmark
Forms![MIW_ISSUESWALL_Issu e Description Entry Form].Requery
'MsgBox x
Forms![MIW_ISSUESWALL_Issu e Description Entry Form].Bookmark = x
I am getting the error
"3159 Not a valid bookmark"
Can anyone help???
Suzanne
My code is as follows:
Dim x As Variant
x = Forms![MIW_ISSUESWALL_Issu
Forms![MIW_ISSUESWALL_Issu
'MsgBox x
Forms![MIW_ISSUESWALL_Issu
I am getting the error
"3159 Not a valid bookmark"
Can anyone help???
Suzanne
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...
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...
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.
Jim.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
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_Issu e 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....
Now I have the following code:
Dim f As Form
Set f = Forms![MIW_ISSUESWALL_Issu
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....
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_Issu e 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!!
f.bookmark=r.bookmark
so the following code works:
Dim f As Form
Set f = Forms![MIW_ISSUESWALL_Issu
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
Brian
Dim x As Bookmark
....or...
Dim x As String
Good Luck
Simon