CurrentDb( ) Method

  • Thread starter Thread starter Jason B
  • Start date Start date
J

Jason B

My syntax as follows:

Private Sub cmdFind_Click()
Dim db As Database
Dim rs As Recordset
...

Set db = CurrentDb()
...

When I run this I get User-defined type not defined. The
help files show I have the right syntax but I get this
error. I know that Database isn't a correct type but
that is the why the help files show it also.

Thanks for the help in advance,
Jason B.
 
Do you have a Reference set to the Microsoft DAO 3.6 Object Library? If
you are using Access 2000 or 2002, it is not set by default and without it,
I believe your attempt to Dimension a database object will error.

To check/set References, open any code window (or press Alt-F11). Then,
from the code menu, select Tools|References. Look at the checked
references; and if Microsoft DAO 3.6 Object Library is not one of them,
scroll through the available references and put a check in the box.

In addition, when using Access 2000 and 2002, there is a reference to ADO
which is set by default, so it is necessary to be explicit about how you
want to read data, so you might want to use your code as follows:
Dim db As DAO.Database
Dim rs As DAO.Recordset
...
Set db = CurrentDb()

hth,
 
Back
Top