Not a valid bookmark error

Hello,
I have created recordset RecipesRS and would like to bookmark the record previous to the one showing on the unbound form:
Dim varBookmark As Variant
Set RecipesRS = db.OpenRecordset("SELECT " & strTableName & ".* FROM " & strTableName & " ORDER BY " & strTableName & ".txtCourse;", dbOpenDynaset)
'The user can scrolll through the recordset in a form.
****************
'This is the part that doesn't work:
RecipesRS.MovePrevious
varBookmark = RecipesRS.Bookmark

I get run-time error '3159': Not a valid bookmark.
Does anyone know what I'm doing wrong?
Thank you.
Saleve
SaleveAsked:
Who is Participating?
 
Rick_RickardsCommented:
If you want to move your form to the prevoius record the code would look something like this...
Dim rst as DAO.Recordset
Set rst = Me.RecordsetClone
rst.BookMark = Me.Bookmark
If rst.BOF = False then rst.MovePrevious
Me.BookMark = rst.BookMark
Set rst = Nothing

Open in new window

0
 
tbsgadiCommented:
Hi Saleve,

Try something like Forms![frmMain].Bookmark = RecipesRS.Bookmark

Good Luck!

Gary
0
 
tbsgadiCommented:
Saleve,


Or Alternatively maybe Dim varBookmark as object

Gary
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
peter57rCommented:
There doesn't seem to be any code that aligns the recordset with the record that is visible on the form?
0
 
clarkscottCommented:
Your error is occuring on the first record returned from your query.
There is no PREVIOUS record therefore no bookmark can be made.

Scott c
0
 
SaleveAuthor Commented:
Hello everyone and thank you for your input.  I will be away for a few days and will look at this as soon as I get back.  I apologize in advance for the delay in assigning points.
Saleve
0
 
SaleveAuthor Commented:
My sincere apologies for the delay.  Ive been out of town&  Thank you for your answers and patience!
0
 
SaleveAuthor Commented:
I actually have code to fill in the fields on the form, as well as to deal with the first record, but thanks for the input.  The accepted solution works for the second record in the recordset ONLY, so I guess my problems go deeper than just this issue....
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.