bill201
asked on
why don't work dao recordsets in access 2010
i put this in my recordset :
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset
and when i make compile i get this error that point on the "set db":
Compile error:
Invalid outside procedure
and i attach a frame picture from the references
reference.jpg
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset
and when i make compile i get this error that point on the "set db":
Compile error:
Invalid outside procedure
and i attach a frame picture from the references
reference.jpg
ASKER
i make like you said but i still get the error message on the "set" word
can you add "Microsoft DAO 3.6 Object Library" in your refrences?
ASKER
i tried it and i get this message:
name conflicts with existing module,project or object library
name conflicts with existing module,project or object library
do you use access 2010 64 bit or 32 bits?
do you have AccDB object library in your reference? if yes, uncheck DAO 3.6 and check accDB object library instead?
if you add AccDB object libary in your refrence, you can try your original code instead.
ASKER
i have access 32 bit
and i don't see the accdb in my reference where can i found it?
and i don't see the accdb in my reference where can i found it?
You don't use DAO 3.6 in Access 2007 or 2010. 2007 and 2010 use the new ACE engine, which requires the references you currently have set.
As pddilan suggests earlier, OpenRecordset require a valid SQL Statement or table/query name:
Set rs = db.OpenReocordset("SELECT * FROM SomeTable")
or
Set rs = db.OpenRecordset("qryGetUs erNames")
However, it seems you're having trouble on the "Set db = CurrentDB". Is that correct?
You really don't need to use a variable for this. You can do this:
Set rs = Currentdb.OpenRecordset('Y our SQL Statement")
If that doesn't work (and you are 100% certain that your SQL statement is valid) then you may have some issues with the installation of Access, or with one of the supporting libraries/files. You may need to do a repair or reinstall of Access or Office.
As pddilan suggests earlier, OpenRecordset require a valid SQL Statement or table/query name:
Set rs = db.OpenReocordset("SELECT * FROM SomeTable")
or
Set rs = db.OpenRecordset("qryGetUs
However, it seems you're having trouble on the "Set db = CurrentDB". Is that correct?
You really don't need to use a variable for this. You can do this:
Set rs = Currentdb.OpenRecordset('Y
If that doesn't work (and you are 100% certain that your SQL statement is valid) then you may have some issues with the installation of Access, or with one of the supporting libraries/files. You may need to do a repair or reinstall of Access or Office.
ASKER
i don't think that you right and this is the problem because still yesterday i was make all the time recordsets like this and nothing happen and yesterday without any specific reason (i don't install or update Microsoft office or any other software at all) it's start to make problems
sorry, typo, I meant "acedao.dll"
C:\Program Files\Common Files\Microsoft Shared\Office14\acedao.dll
C:\Program Files\Common Files\Microsoft Shared\Office14\acedao.dll
ASKER
any way i try this code Set rs = Currentdb.OpenRecordset ("numberst")
and it's not work so i will reinstall access 2010
and it's not work so i will reinstall access 2010
so you said you don't have problem yesterday. maybe you need to repair and compact your databse. j
ASKER
it's not just in one database it's in every database that i open even new one (except of vba windows where i put before yesterday a recordset there is working and i can even add more stuff to the code)
ASKER
i add this file C:\Program Files\Common Files\Microsoft Shared\Office14\acedao.dll
and it's seems that this file was there before and anyway it's not working
and it's seems that this file was there before and anyway it's not working
ASKER
i uninstall office and reinstall it again but the problem remains
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
you are so right it's embarrassing that i don't notice this
<<you are so right it's embarrassing that i don't notice this >>
I tell you it's amazing sometimes what you filter out when reading an error. I've been caught like that sooo many times myself over the years it is not even funny.
Have a great day,
JimD.
I tell you it's amazing sometimes what you filter out when reading an error. I've been caught like that sooo many times myself over the years it is not even funny.
Have a great day,
JimD.
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("select somefiled from table")