TYPE MISMATCH ERROR AGAIN!

PAMPEREDBECCA

New member
Local time
Today, 11:33
Joined
Aug 6, 2000
Messages
9
I posted a couple of days ago on the Type Mismatch error. I am getting the same error in almost every function I write using SET. Does anyone have any ideas? My function is below.

Option Compare Database
Option Explicit

Dim db As Database
Dim RstTmp As Recordset
Dim Loop1 As Variant
Dim SqlStr As String

Function emaillist()
Set db = CurrentDb
SqlStr = "SELECT tableemail.emailaddress FROM tableemail;"

'I am getting the error on the line in between the rows of asteriks.

**************************************

Set RstTmp = db.OpenRecordset(SqlStr, dbOpenSnapshot)

**************************************
DoEvents
On Error Resume Next
RstTmp.MoveLast
RstTmp.MoveFirst
On Error GoTo 0
If RstTmp.RecordCount = 0 Then
MsgBox "There are no e-mail addresses to send at this time."
Exit Function
End If
For Loop1 = 1 To RstTmp.RecordCount
DoCmd.SendObject acSendNoObject, , , RstTmp.Fields![emailaddress].Value, , , , , True


RstTmp.MoveNext
Next Loop1

MsgBox (Loop1 - 1) & "Messages sent!"

End Function
 
Just for fun I pasted your code in a module and it compiled without a hitch. The only thing that I can think of to try is when you are on that module, or any module for that matter, select Tools | References and see if there are any items in the list marked "Missing". If so, uncheck them.

HTH,
Jack
 
set db = currentdb is a dao call. Make sure you have your dao object library referenced. It's default in A97, but not in A2K. Check your references with a module open under tools|references
 
I had the same problem. This is definitely a problem with Access version that you run. You must be using 2000. Somewhere deep indside the help files (!) a list of changed commands are declared. Recordset command is one of them.
I fixed my problem by typing:
Dim db As Database
Dim rs As DAO.RecordSet

Set db = CurrentDb()
Set rs = db.OpenRecordset("TableName")

Notice the difference DAO.Recordset instead of just Recorsdet.
Also the previous reply is important, make sure that you have the "Microsoft DAO 3.6 Object Library" checked under references.

Hope it helps,

Emre
 

Users who are viewing this thread

Back
Top Bottom