I have this database (Access 97) for the storage of constituents in a community. I have a field called Email1 and I would like to do a query on people who have email addresses and send them all an email by BCC. I have this code for the OnClick pushbutton:
Private Sub Command85_Click()
Dim MyEmailList As String
MyEmailList = ColumnToLine("QryEmail", "Email1"
DoCmd.SendObject , , , "chris.whitten@ottawa.com", , MyEmailList, "Test Message", , True
End Sub
I also have this code in the General Module:
Function ColumnToLine(QryEmail, email1)
On Error GoTo ErrInFunction
Dim myRs As DAO.Recordset
Dim ResultString As String
Set myRs = CurrentDb.OpenRecordset("QryEmail"
If myRs.RecordCount > 0 Then
Do Until myRs.EOF
ColumnToLine = ColumnToLine & IIf(Len(ColumnToLine) = 0, "", "; "
& myRs(ColumnName)
myRs.MoveNext
Loop
End If
FinishPoint:
On Error Resume Next
'MsgBox ColumnToLine
myRs.Close
Exit Function
ErrInFunction:
ColumnToLine = "Error: " & Err.Description
Resume FinishPoint
Exit Function
End Function
I am getting an error - Compile Error:
User-defined type not defined
The first line is highlighted - Function ColumnToLine(QryEmail, email1) - and the DAO.Recordset is also. Wha can be my problem??????
Thanks
Chris
Private Sub Command85_Click()
Dim MyEmailList As String
MyEmailList = ColumnToLine("QryEmail", "Email1"
DoCmd.SendObject , , , "chris.whitten@ottawa.com", , MyEmailList, "Test Message", , True
End Sub
I also have this code in the General Module:
Function ColumnToLine(QryEmail, email1)
On Error GoTo ErrInFunction
Dim myRs As DAO.Recordset
Dim ResultString As String
Set myRs = CurrentDb.OpenRecordset("QryEmail"
If myRs.RecordCount > 0 Then
Do Until myRs.EOF
ColumnToLine = ColumnToLine & IIf(Len(ColumnToLine) = 0, "", "; "
myRs.MoveNext
Loop
End If
FinishPoint:
On Error Resume Next
'MsgBox ColumnToLine
myRs.Close
Exit Function
ErrInFunction:
ColumnToLine = "Error: " & Err.Description
Resume FinishPoint
Exit Function
End Function
I am getting an error - Compile Error:
User-defined type not defined
The first line is highlighted - Function ColumnToLine(QryEmail, email1) - and the DAO.Recordset is also. Wha can be my problem??????
Thanks
Chris