Type mismatch (error 13)Access 2000

  • Thread starter Thread starter Lisa B.
  • Start date Start date
L

Lisa B.

Can anyone tell me why I get a type mismatch (error 13) when I run the
following code in Access 2000 and How to fix it

The same code works when run in access 97

The error occures at the line : Set SourceRS = TheDB.OpenRecordset(..)
___________________________________
Public Function CheckRequired(FieldName As String) As Boolean
'Check to see if field is Required
Dim TheDB As Database
Dim SourceRS As Recordset

Set TheDB = CurrentDb
Set SourceRS = TheDB.OpenRecordset("tblRequiredFields", dbOpenDynaset)

If SourceRS.RecordCount Then
SourceRS.MoveFirst

Do Until SourceRS.EOF

If SourceRS!FieldName = FieldName Then
CheckRequired = True
End If
SourceRS.MoveNext
Loop
End If
SourceRS.Close
End Function
_________________________________

Any suggestions are greatly appreciated
 
Hi Lisa,

You need to dim your Recordset as DAO.Recordset. Then go
to tools>references and add the MS DAO 3.6 library.

Regards,
Jen
 
The only thing that springs to mind is you have a mix of (database) DAO and
(recordset)ADO. Do you have references set to DAO?
What happens when you explicitly declare the variables?

Dim TheDB As DAO.Database
Dim SourceRS As DAO.Recordset
 
Back
Top