Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record counting code 1

Status
Not open for further replies.

asmall

Programmer
Dec 26, 2002
31
US
I'm trying to count the number of records in a recordset, but the code I'm using is causing an error. I have used this code in Access 97 but when I convert to Access 2000 I get a type 'Run-Time Error 13 Type missmatch' error. This is the code.

Dim recPosition As Recordset

Set recPosition = Me.RecordsetClone()<-this is where the error occurs

recPosition.Bookmark = Me.Bookmark

Me![RecordPosition] = "Check " & (recPosition.AbsolutePosition + 1) & " of "
recPosition.MoveLast

Me![RecordPosition] = Me![RecordPosition] & recPosition.RecordCount

recPosition.Close

P.S.- "RecordPosition" is the name of the textbox.

Thanks for your help!
 
asmall
It seems to me I ran into something like this before. As I recall, it depends on whether you are using DAO or ADO. One uses RecordsetClone() and the other just RecordSet, or something such as that.

Open your VBA screen (Alt F11), and under Tools check the References. Make sure that Microsoft DAO 3.6 is checked.

Tom
 
To add to what Tom said,

change Dim recPosition As Recordset
to Dim recPosition As DAO.Recordset
then Set recPosition = Me.RecordsetClone
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top