recordset type mismatch

  • Thread starter Thread starter user
  • Start date Start date
U

user

Hello everybody,

I'm using trying to search records in Access 2002 for a hospital
database, but the following code snippet gives me a type mismatch:

Dim pat_data As Recordset
Set pat_data = CurrentDb.OpenRecordset("general patient data")

What am I overlooking?

Thanks in advance

Chris
 
Both the DAO library and the ADO library have a Recordset object.
CurrentDb is supplied by DAO, so try:
Dim pat_data As DAO.Recordset

You may need to choose References from the Tools menu, and check the box
beside:
Microsoft DAO 3.6

More on these references:
http://allenbrowne.com/ser-38.html
 
Try changing your Dim statement to

Dim pat_data As DAO.Recordset

If this causes a compile error then in the code window go to
Tools|References. Scroll down until you find Microsoft DAO 3.6 Object
Library and place a check next to it. Click ok to close.

The problem is that Access 2000 and new use ADO by default instead of DAO.
Both of these object models have an object called Recordset. Access will use
them in the order that the checked references are listed in the references
window (i.e. it uses the first one it finds). Specifying DAO in the Dim
statement forces Access to use the one you want.
 
Back
Top