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

Type mismatch error 13 1

Status
Not open for further replies.

jmeckley

Programmer
Jul 15, 2002
5,269
US
I am getting an error when i run this piece of code. I have used this code in the past and it works, for some reason i cannot get it to work now.
*****
Dim TestStr As String
Dim qdfTemp As QueryDef
Dim DB As Database
Dim ChkRst As Recordset

'Check to see if the record does exists
TestStr = "select 1 from Event_tbl where InstitutionID = " & I & " and EventDate = #" & D & "#;"
Set DB = CurrentDb
Set qdfTemp = DB.CreateQueryDef("", TestStr)
GetrstTemp qdfTemp
Set ChkRst = qdfTemp.OpenRecordset(dbOpenDynaset, dbSeeChanges)

'Update event table if the record does not exists
If ChkRst.RecordCount > 0 Then
MsgBox "Error Message"
Else
SqlStr = "select * from table"
DoCmd.SetWarnings False
DoCmd.RunSQL SqlStr
DoCmd.SetWarnings True
End If

ChkRst.Close
Set ChkRst = Nothing
*****
Public Function GetrstTemp(qdfTemp As QueryDef)
Dim restemp As Recordset
Dim response As String

With qdfTemp
Set rstTemp = .OpenRecordset(dbOpenDynaset)
With rstTemp
If RecordCount = 0 Then
Exit Function
Else
.MoveLast
.Close
End If
End With
End With
End Function
*****

Thank you for your assistance, Jason Meckley
Database Analyst
WITF
 
The error in Access 2000 or above, is usually due to missing the reference to the DAO library or not explicitly defining the data objects with the library prefix.

Dim ChkRst As DAO.Recordset '- for DAO objects

Dim ChkRst As ADODB.Recordset '- for ADO objects

The reason for the error is that both the DAO and ADO libraries use some methods with the same name and Access uses a different default depending???
Some data objects are Recordset, Field, etc.

 
thank you, that solved the problem. Jason Meckley
Database Analyst
WITF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top