Me.Recordset.Move

RobinL

Registered User.
Local time
Today, 05:50
Joined
Mar 27, 2002
Messages
27
Dear all,

I would like to move to record number x in a recordset using

me.recordset.move x, 1

However, I keep getting a "not a valid bookmark" error.

The .move method only seems to take one parameter, contrary to what the following article says:
http://www.w3schools.com/ado/met_rs_move.asp

What am I missing? Does the form's recordset object take different methods to an ADO recordset?

Of course, I can achieve the same effect using:

me.recordset.movefirst
me.recordset.move x

but that doesn't help me to understand why I can't get .move to work with two parameters!

Thanks so much for any help,

Robin
 
The second parameter is a bookmark object. You are supplying an integer.

From what you've explained you only need the first parameter, so use just that.
 
Me.Recordset is most likely using a DAO recordset and not an ADO recordset, the second argument for a DAO type is different.
'From help file
Moves the position of the current record in a Recordset object.
Syntax
recordset.Move rows, start
The Move method syntax has these parts.
Part Description recordset An object variable that represents the Recordset object whose current record position is being moved. rows A signed Long value specifying the number of rows the position will move. If rows is greater than 0, the position is moved forward (toward the end of the file). If rows is less than 0, the position is moved backward (toward the beginning of the file). startbookmark Optional. A Variant (String subtype) value identifying a bookmark. If you specify startbookmark, the move begins relative to this bookmark. Otherwise, Move begins from the current record.
 
Good point DJKarl.

Make sure you are explicit in your declarations of the Recordset object you wish to use.
 
Thanks very much for the help. Sorry for it being such an easy answer! (I did try googling first)
 
Just one thing to be added here. Record numbers are NOT something you should be even concerned about because they DO NOT always refer to the same record. It is just a count mechanism which is SPECIFIC to the currently opened recordset and if there is no sort order applied (for example, you have used the table instead of a query for the form's recordset) there is no guarantee that the records will be in the same order as you had seen them before. So opening the table one time a record could fall as record 5, but the next time you open it, it can be record 8.

The record numbers ONLY apply to that particular instance of a recordset and no others. So you should do a FindFirst based on the PRIMARY KEY of the record instead.
 
Thanks Bob. I couldn't find many examples on the net of the .move command being used. Your post explains why!
 

Users who are viewing this thread

Back
Top Bottom