Getting a type mismatch error when trying to run code

  • Thread starter Thread starter John
  • Start date Start date
J

John

Here is the code that I am trying to run. What I am
trying to do is look at a recordset (Table: TestData) and
if there are no records in the table then open up one form
otherwise opening up another form. The code blows up at
on the "Set rst = db.OpenRecordSet("TestData") and I get a
error message saying "Type Mismatch". I can see what I am
doing wrong?

Thanks in advance,

Here is the code:

Dim db As Database
Dim rst As Recordset

Set db = CurrentDb()
Set rst = db.OpenRecordset("TestData")

If rst.EOF = True Then
DoCmd.OpenForm "Success"
Else
DoCmd.OpenForm "tblToolWatchBad"
End If
 
Hi,
You probably have a reference set to ADO as well as DAO.
Either remove the ADO reference or use this declare:
Dim rst As DAO.Recordset

HTH
Dan Artuso, MVP
 
Back
Top