Type mismatch using DAO

  • Thread starter Thread starter Alfred B
  • Start date Start date
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
 
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.
 
Back
Top