Type Mismatch

L

Leonard

Can anyone tell me why I keep getting a "Run-time error
13... Type Mismatch" on the following code?

Any help appreciated.

'===========================================
Dim dbs As Database, rst As Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("MyQuery")

If rst.RecordCount >= 1 Then
MsgBox "At least one record has been entered"
End If
'===========================================
 
V

Van T. Dinh

Both ADO and DAO have the Recordset Object and your rst is
defaulted to ADO Recordset while you need DAO Recordset.

Disambiguate your dec. like:

Dim dbs As Database
Dim rst as DAO.Recordset

HTH
Van T. Dinh
MVP (Access)
 

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