opening a recordset

W

WilliamI

I cannot figure out why I keep getting an Error 13 Type Mismatch on "Set rst
= db.OpenRecordset("Purchases")". This code structure has always worked
before in programming datablases. I get this same error on other recordsets
that I have tried to create in this database. Is there a corruption or Access
options setting problem that could be occurring?

Dim db As Database, rst As Recordset, v As Long
Set db = CurrentDb
Set rst = db.OpenRecordset("Purchases")
rst.MoveLast
v = rst!VouchID 'VouchID data type is a Long Integer in the
Purchases table
rst.Close
Forms!frmPurchases!VouchID = v + 1
 
V

Van T. Dinh

You probably have both DAO and ADO Library in the References and the ADO
Library has higher priority. In this case the Recordset is dimendioned as
ADO Recordset which is not compatible with your code.

Change your declaration to:

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim v As Long
 

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