Type mismatch using DAO

A

Alfred B

Hi! I'm trying to open recordset with macro using DAO. The syntax is:

1 dim myDB as Database
2 dim myTable as Recordset

3 set myDB as CurrentDb
4 set myTable = myDB.OpenRecordset("tblMyTable")

and I get Type mismatch in row 4???

Regards, Alfred
 
V

Van T. Dinh

Change the Dim to:

Dim myTable As DAO.Recordset

if you don't use "DAO" and ADO Library is of higher priority than DAO
Library, VBA will dim your myTable as an ADO Recordset which is not suitable
for your code.
 

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