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
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