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

Recordset Initialization Help

Status
Not open for further replies.

thoms314159

Technical User
Apr 8, 2003
13
0
0
CA
I can't figure out what's the matter with this piece of VBA code. Please help.

Option Compare Database
Option Explicit
Private dbCurrent As Database
Private qdfInputInf As QueryDef
Private rsTemp As Recordset

Function InflationCalculator(YearWanted As Integer, YearEntered As Integer) As Double
Set dbCurrent = CurrentDb
Set qdfInputInf = dbCurrent.QueryDefs("qryInputInf")
Set rsTemp = qdfInputInf.OpenRecordset()
....
End Function

This piece of code compiles fine, but when I step through the code in the debugger, I get a "Run-time error '13': Type mismatch" on the line "Set rsTemp = qdfInputInf.OpenRecordset()". Please note that everything up to that line is fine; all variables contain the data that they should, but rsTemp contains no data. Oh yeah, and I did explicitly select the reference to the DAO 3.6 Object Library.

Please help!
Thanks in advance.
 
Two possible causes:

1. You have a reference to an ADO Recordset, confusing everything. Explicitly define "rsTemp as DAO.Recordset".

2. Querydef-built recordsets are unnecessary. Instead consider the line:
Code:
Set rsTemp = CurrentDB.OpenRecordset("qryInputInf")

then you don't have to worry about declaring a database object or a querydef object.

--
Find common answers using Google Groups:

Corrupt MDBs FAQ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top