Need help with code on Access 2002

darag2358

Registered User.
Local time
Today, 23:46
Joined
May 4, 2001
Messages
28
I've been used to Access 97 and just went to Access 2002 and need some help on a basic issue. I'm trying to create and open a recordset, but I'm getting errors. Here's the partial code.

Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset("Holidays", dbOpenDynaset)

These are the first two lines of the code and it doesn't get past this point. I'm getting Run-time error 3001 Invalid Argument at the 2nd line (the "set" statement).

If I remove the 'dbOpenDynaset' argument, then I get Run-time error 13 Type Mismatch at the same line.

Something different in XP?

TIA
 
The reason is that you are using DAO syntax in an ADO environment. Access 2002 uses the ADO library by default and sets an ADO type recordset object if you do not explicitly declare it otherwise...
So you have two choices. Set a reference to the DAO library and continue to use the DAO object library. I think you need to either ensure that you expicitly declare your objects of DAO type -

Dim rst as DAO.Recordset

... Or you have to ensure the DAO reference comes before the ADO reference in your list. I stress THINK here.

Alternatively you could start using the ADO library which is a bit harder as you will have to learn the new methods and properties and so forth.

Probably the former is the way you want to go. Converting an existing db can be time consuming depending on how much code you have.

Chris
 
that fixed it, thanks

Looks like I've got a lot of work to do. Appreciate the help.
 

Users who are viewing this thread

Back
Top Bottom