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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Kind of Stuck!!!!!

Status
Not open for further replies.

Cricker

Technical User
Sep 11, 2002
31
CA
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
 
I believe the following line contains the problem:

ColumnToLine = ColumnToLine & IIf(Len(ColumnToLine) = 0, "", "; ") & myRs(ColumnName)

It should be:

ColumnToLine = ColumnToLine & IIf(Len(ColumnToLine) = 0, "", "; ") & myRs("ColumnName")

NOTE the double quotes around ColumnName.
 
Thanks, but the the problem is still there.... the first line is highlighted.....

Function ColumnToLine(QryEmail, email1)
On Error GoTo ErrInFunction

and the following line is marked also??? could it be DAO???

Dim myRs As DAO.Recordset

chris
 
I don't know. Your code compiles under Access 95 and Access 2000 (I don't have Access 97). However, you might try commenting out the following 2 lines from your code just to see if it compiles without those lines:

'commentout ColumnToLine = ColumnToLine & IIf(Len(ColumnToLine) = 0, "", "; ") & myRs(ColumnName)

'commentout ColumnToLine = "Error: " & Err.Description

If, by commenting out those 2 lines, your program compiles, then change you function statment to:
Function ColumnToLine(QryEmail as string, email1 as string) as String
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top