Solved

Not a valid bookmark error

Posted on 2007-12-03
8
2,285 Views
Last Modified: 2013-11-29
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
0
Comment
Question by:Saleve
8 Comments
 
LVL 46

Assisted Solution

by:tbsgadi
tbsgadi earned 33 total points
ID: 20395242
Hi Saleve,

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

Good Luck!

Gary
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 20395247
Saleve,


Or Alternatively maybe Dim varBookmark as object

Gary
0
 
LVL 77

Assisted Solution

by:peter57r
peter57r earned 33 total points
ID: 20395267
There doesn't seem to be any code that aligns the recordset with the record that is visible on the form?
0
 
LVL 20

Assisted Solution

by:clarkscott
clarkscott earned 34 total points
ID: 20395283
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 16

Accepted Solution

by:
Rick_Rickards earned 400 total points
ID: 20395315
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
 

Author Comment

by:Saleve
ID: 20398240
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
 

Author Comment

by:Saleve
ID: 20521728
My sincere apologies for the delay.  Ive been out of town&  Thank you for your answers and patience!
0
 

Author Closing Comment

by:Saleve
ID: 31412310
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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now