Error message '13 Type Mismatch' HELP!

G

Gina Whipp

I don't know if anyone can help but here it goes. I am trying to understand
this code. I almost had it except now get the error message '13 Type
Mismatch' and when I press debug I get... Set rs = 0 (see where below). I
don't understand can someone help?

As usual thanks in advance!
Gina Whipp

Function fillBDays()
Dim irow As Integer
Dim icol As Integer
Dim tuseday As String
Dim tcheckday As String
Dim ans As String
Dim db As Database
Dim qd As QueryDef
Set db = CurrentDb()
Dim rs As Recordset
Set qd = db.QueryDefs("qryGetMonthBirthdays")
qd!findMonth = Me!Month
Set rs = qd.OpenRecordset() ERRORS OUT HERE Set rs = 0
Dim done As Integer
done = 0
If rs.EOF And rs.BOF Then
Else
Do Until rs.EOF
If Trim(rs!ClientName & "") = "" Then
Else
ans = ""
For irow = 1 To 6
For icol = 1 To 7
tuseday = rs!Day
tcheckday = Trim(Left(Me("lbl" & irow & icol).caption, 2))
If tcheckday = tuseday Then
Me("lbl" & irow & icol).caption = Me("lbl" & irow &
icol).caption & vbCrLf & rs!ClientName
done = 1
End If
If done = 1 Then Exit For
Next icol
If done = 1 Then Exit For
Next irow
End If

rs.MoveNext
done = 0
Loop
End If
rs.Close
Me!ClientIDList.Requery

End Function
 
K

Kevin

Gina,

Check your query. I suspect you have two fields joined in
the query that are not of the same type.

Hope that helps!

Kevin
 
G

Gina Whipp

Kevin,

The query has no joins it's based on a single table. (Unless I miss
understood.) I can open the query just fine. Perhaps if I understood what
Set rs = qd.OpenRecordset() is trying to do. I assumed it was opening my
query "qryGetMonthBirthdays" but now I am not so sure.

Thanks..
Gina
 
G

Gina Whipp

Please note, I did not write this code... it's from an old sample database
done in Access 97. I can no longer locate the site I downloaded it from
8-( But I don't like using something without understanding what it is
doing.
 
F

Fred Boer

Dear Gina:

Could you be having a "references" problem?

I'm not an expert, so I'll quote one: (Van T. Dinh - a quick cut/paste from
Google groups..)

<snip>

Are you using A2K or AXP? If you are, the problem is that your Recordset
"rs" has probably defaulted to ADO Recordset in the Dim statement while your
code required it to be DAO Recordset. Both DAO & ADO has an object by the
name "Recordset". Unfortunately they are *not* compatible. Hence, you got
the Type Mismatch Error.

Since the Database is OK, you already had the DAO Object Library in your
References. All you need to do is to fully declare the Recordset as:

Dim db As DAO.Database, rs As DAO.Recordset

(actually, you don't need "DAO" in front of Database but it is a good
practice to remind you the "DAO" for the Recordset).

FYI, to be *very* careful, I do the following:

1. Make sure DAO Object Library in included in the References.

2. Move DAO in the References Dialog so that it has higher Priority.

3. Better still, remove ADO from the References if you don't use it.

4. Always fully qualify the objects in the Dim statement with "DAO." if
you want to use DAO.

<endsnip>


You can read more than I could imagine anyone would want to know about it at
:

http://members.rogers.com/douglas.j.steele/AccessReferenceErrors.html

HTH
Fred Boer
 
P

Paul Overway

You need a reference to DAO. See Tools|References while in VBA. If you
don;t need ADO, you should remove that reference. If you do, you need to
preface your variables with DAO, i.e., DAO.Recordset
 
G

Gina Whipp

THANK YOU THANK YOU THANK YOU

It was indeed a reference problem THANKS to you and THANKS to Van! It is
solved and working!

Gina
 

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