Are you coding in Access (Module) when you get this error or are you using another program trying to create this variable. It sounds like you do not have your references set
1 - Ensure you have a reference to the library you are going to use (Microsoft DAO 3.# Object Library/Microsoft ActiveX Data Objects 2.# Library)
2 - Do an explicit declaration - i e explicitly refer the relevant library (on all object declarations of objects relating to these libraries):
[tt]dim rs1 as dao.recordset
dim rs2 as adodb.recordset[/tt]
You have to reference either Microsoft DAO Object library or Microsoft ActiveX Data Objects Library (for ADO).
When in VBE, menu Tools -> References ...
And feel free to strong typing to avoid ambiguity:
Dim rst As DAO.Recordset
or
Dim rst As ADODB.Recordset
Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
Keep in mind RoyVidar's post assumes you want to early bind. I like early bind while writing the program, and if I'm the only one using it I usually keep it that way. If I plan on giving the code to someone else to use, I recommend changing to a late bind before distribution
Dim rs1 as object
...
Set rs1 = CreateObject("ADODB.Recordset")
...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.