Type mismatch (error 13)Access 2000

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
 
J

Jen

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
 
J

JohnFol

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top