How do I move to last record on form when it loads?

D

Dave

The code below produces a Type Mismatch error when I try to set rsClone as
Me.RecordsetClone():

Dim rsClone As Recordset

Set rsClone = Me.RecordsetClone()

If rsClone.RecordCount > 0 Then
rsClone.MoveLast
rsClone.Bookmark = Me.Bookmark
End If

Likewise so does this:

Dim rs As Recordset

Set rs = Me.Recordset
rs.MoveLast

How do I move to the last record in my form?
 
K

Ken Snell

Likely you're using ACCESS 2000 or 2002. You need to add the DAO library to
the references (VBE: Tools | References) and then disambiguate the
Recordset dim. A form recordset is a DAO recordset, not an ADO recordset.

Dim rsClone As DAO.Recordset

Also, your code logic is wrong. This line:
rsClone.Bookmark = Me.Bookmark
should be this:
Me.Bookmark = rsClone.Bookmark
 
D

Dave

Ahh...Thank you again Ken.


Ken Snell said:
Likely you're using ACCESS 2000 or 2002. You need to add the DAO library to
the references (VBE: Tools | References) and then disambiguate the
Recordset dim. A form recordset is a DAO recordset, not an ADO recordset.

Dim rsClone As DAO.Recordset

Also, your code logic is wrong. This line:
rsClone.Bookmark = Me.Bookmark
should be this:
Me.Bookmark = rsClone.Bookmark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top