What version of Access are you using, and what version did you copy the code from?
At a guess, you've copied code from Access 97 (or earlier) into an Access 2000 db. If this is correct, use the format
Dim CurDB As ADODB
You could also check your references (from any module "TOOLS|References" from the menubar) to ensure that Microsoft DAO 3.51 Object Library is checked. If not, add it to your references.
HTH
Lightning