It's DAO.
First, be SURE there is a Reference set to Microsoft DAO. 3.6 Object Library
VBA Editor>>Tools>>References ... see attached screen shot
Then, try changing:
Dim db As Database
Dim rs As Recordset
Dim db2 As Database
Dim rs2 As Recordset
To
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim db2 As DAO.Database
Dim rs2 As DAO.Recordset