I have a command button which sets up an email list based on names selected from a RSVP list. I had this working for awhile but now I get a "type mismatch" code error when I try to run it. The code is shown below and the type mismatch occurs on the following line: Set RS = mydb.OpenRecordset("rsvp_query")
Any thoughts on how to correct this?
Thanks Garyhou
Private Sub emailRSVP_Click()
Dim mydb As Database, RS As Recordset
Dim strBody As String, lngCount As Long, lngRSCount As Long
Dim strTo As String
Dim strlist As String
Set mydb = DBEngine.Workspaces(0).Databases(0)
Set RS = mydb.OpenRecordset _
("rsvp_query")
lngRSCount = RS.RecordCount
If lngRSCount = 0 Then
MsgBox "No member email addresses found.", vbInformation
Else
RS.MoveLast
RS.MoveFirst
Do Until RS.EOF
lngCount = lngCount + 1
If RS!rsvp = -1 Then strlist = strlist & RS!email_addr & ";"
strlist = Left$(strlist, Len(strlist) - 1)
Me!txtselected = strlist
RS.MoveNext
Loop
End If
RS.close
mydb.close
Set RS = Nothing
Set mydb = Nothing
Close
End Sub
Any thoughts on how to correct this?
Thanks Garyhou
Private Sub emailRSVP_Click()
Dim mydb As Database, RS As Recordset
Dim strBody As String, lngCount As Long, lngRSCount As Long
Dim strTo As String
Dim strlist As String
Set mydb = DBEngine.Workspaces(0).Databases(0)
Set RS = mydb.OpenRecordset _
("rsvp_query")
lngRSCount = RS.RecordCount
If lngRSCount = 0 Then
MsgBox "No member email addresses found.", vbInformation
Else
RS.MoveLast
RS.MoveFirst
Do Until RS.EOF
lngCount = lngCount + 1
If RS!rsvp = -1 Then strlist = strlist & RS!email_addr & ";"
strlist = Left$(strlist, Len(strlist) - 1)
Me!txtselected = strlist
RS.MoveNext
Loop
End If
RS.close
mydb.close
Set RS = Nothing
Set mydb = Nothing
Close
End Sub