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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem running query with VBA 1

Status
Not open for further replies.
Jun 4, 2003
5
US
OK, I'm a little stumped.

Here's the code:
Dim stDocName As String
stDocName = "rpt_rev_sum"

Dim db As Database
Dim dbf As QueryDef
Dim records As Recordset

Dim startdt As Date
Dim enddt As Date

Set db = CurrentDb()
Set dbf = db.QueryDefs("rpt_rev_sum")

dbf.SQL = "select distinct pd_no from deltek.rpt_rev_sum where fy_cd = '2003';"

'Set records = dbf.OpenRecordset -> THIS ONE IS FAILING

'DoCmd.OpenQuery stDocName, acNormal, acEdit -> THIS ONE WORKS

So this will open if i use the OpenQuery function, but I can't do OpenRecordset. It gives me: Type Mismatch. Any ideas?
 
That type mismatch is because the Tools, References MS DAO 3.6 Library is not clicked. It is a way down the list. The the dim statement is: "dim rs as dao.recordset"

The reason for this is 2000 and up use the ADO protocol and you are rightly, in my opinion, using DAO.

rollie@bwsys.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top