Hello CJ
I have added the code you highlighted in red and it still falls over with the same error message, below is the script thus far. Can you help me understand what this end of the SQL statement is suppose to do and perhaps I can help you to help me. I can see that it's selecting the fields bfast to tdate from the sales table into a recordset called rs the WHERE condition with MembersID=" & MemID I don't get.
"SELECT ID,bfast,lunch,dwine,bar,desert,cellar,table,tdate FROM sales WHERE MembersID=" & MemID)
Public Function emailbodfunc(MemID As Long) As String
Dim rs As Recordset
Dim db As Database
Dim email As String
Dim BodyStr As String
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT ID,bfast,lunch,dwine,bar,desert,cellar,table,tdate FROM sales WHERE MembersID=" & MemID)
BodyStr = ""
While Not rs.EOF
BodyStr = BodyStr & rst.Fields(0) & "|" & rs.Fields(1) & "|" & rs.Fields(2) & vbCrLf '(linefeed) appreciate only test data but suggest using pipes since spaces could get lost if text either side has spaces -
also means it can easily posted into another db
rs.MoveNext
Wend
If BodyStr <> "" Then BodyStr = "ID " & "Item " & "|" & "Quantity " & vbCrLf & BodyStr 'add a header
emailbodfunc = BodyStr
Set rs = Nothing
Set db = Nothing
End Function
Public Sub emailaddressfunc()
Dim rs As Recordset
Dim db As Database
Dim BodyStr As String
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT Firstname, Surname, emailaddress,ID FROM members;") 'need to add an order by condition
While Not rs.EOF
BodyStr = emailbodfunc(rs.Fields("ID"))
If BodyStr <> "" Then DoCmd.SendObject acSendNoObject, Null, Null, rs.Fields("emailaddress"), Null, Null, "Test subject", BodyStr
rs.MoveNext
Wend
Set rs = Nothing
Set db = Nothing
End Sub