Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OpenRecordSet? (and thanks steve101!)

Status
Not open for further replies.

xq

Programmer
Jun 26, 2002
106
0
0
NL
i'm pretty new with access vba, i've written this small piece of code, but got Type mismatch error on this sentence,
"Set rs = dbs.OpenRecordset(sql)",
couldn't figure out why this is happening. that's the code below

sub query
Dim sql As String
Dim rs As Recordset
Dim dbs As Database

Set dbs = CurrentDb
sql = ""
sql = "SELECT * FROM Creditor"
Set rs = dbs.OpenRecordset(sql)

rs.Close
dbs.Close
end sub

just cann't fix it, any body can help me?
 
Hi, I could not figure out what was wrong with your procedure so I tried it in my database (I even created a Creditor table) and it works just fine... The only thing I can think of is the reference (menu tool -> references) Make sure the Microsoft DAO 3.6 object library is selected. I hope this helps.
 
thanks anyway, and i've set up MS DAO 3.6 object library. thank u!
 
xq,

try this when you declare the rs variable

dim rs as DAO.recordset

that should fix the problem I believe.

HTH,

Griz
 
it does work, thank u!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top