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.
 
Top