@Micron,
I have Access 2010.
If I try to add a reference to the "Microsoft DAO 3.6" library, I get an error: "Name conflicts with existing module, project of object library".
Sometimes I get compile errors (sometimes on built in functions, as in Mid or Left); I then have to add reference(s) to: "Microsoft Office 14.0 Object Library" and/or "Microsoft Office 14.0 Access database engine Object Library". (one or both)
IIRC, "Microsoft DAO 3.6" has been superseded/replaced by "Microsoft Office 14.0 Object Library" and/or "Microsoft Office 14.0 Access database engine Object Library"...... At least for A2010 and later.
EDIT:
Whoops!!
Tried compiling Micron's code with the reference "Microsoft Office 14.0 Object Library".... choked on the line "Dim db As DAO.Database".
The error is "Compile Error: User-defined type not defined"
ridders52 is correct. I set a reference for "Microsoft Office 14.0 Access database engine Object Library" and the code compiled OK.