Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I keep Getting a Type Mismatch Error 1

Status
Not open for further replies.

deharris2003

Programmer
Jul 1, 2003
41
US
I continue to get a type mismatch error and I cannot seem to understatnd why. I am calling this function from a macro. Any help is much appreciated. Here is my code

Function SendMail(expr1 As String, strMessage As String)

Dim dbs As Database 'Holder for database to be updated
Dim rst As Recordset 'Create recordset called rst
Dim strSQL As String 'Holder for SQL statement
Dim strHP As String 'Holder for Helath Plan Name
Dim strEmail As String 'holder for email name
Dim strbody As String 'Holder for Message Body

' Return reference to current database.
Set dbs = CurrentDb
'Find record to send email to
strSQL = "SELECT Name, Email " & _
"FROM Email"

Set rst = dbs.OpenRecordset(strSQL)

Do While Not rst.EOF

strHP = expr1
strEmail = rst("Email")

If strMessage = "Done" Then
strbody = vbCrLf & vbCrLf & _
"Please note that " & strHP & " has been updated on the web."
ElseIf strMessage = "Start" Then
strbody = vbCrLf & vbCrLf & _
"Please note that " & strHP & " is in the process of being updated." & vbCrLf & _
"We apoligize for this inconvience. You will recieve an email when" & vbCrLf & _
"This process is completed."
End If

' send email.
DoCmd.SendObject acSendNoObject, "", acFormatTXT, strEmail, , , strHP, strbody, False

rst.MoveNext
Loop

End Function
 
If you're using Access 2000, then you need to first reference "Microsoft DAO 3.6 Object Library". The declare your variables like this:

Dim dbs As DAO.Database 'Holder for database to be updated
Dim rst As DAO.Recordset 'Create recordset called rst
 
Thank You Very Much. I tried what you said and it worked great.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top