Hello people
This is driving me MAD!!!, I have read hundreds of topics in this forum and still Ican't get it to work
I Want to sent a e-mail to adresses from a query using a selection on a form. I have a lot of names
in a table and each name has one or more selection codes (like: school or theater). In a form (Frmzoeken) i have a listbox with the selection codes in it
, so when i select school i see all the schools on a subform in a query (Qryfrmzoeken):
SELECT TblAdressen.AdresID, TblAdressen.Naam, TblAdressen.BezoekStraat, TblAdressen.BezoekPostcode, TblAdressen.BezoekPlaats, TblAdressen.PostStraat, TblAdressen.PostPostcode, TblAdressen.Postplaats, TblAdressen.Email, TblAdressen.Selectiecode, TblAdressen.Trefwoorden
FROM TblAdressen
WHERE (((TblAdressen.Selectiecode) Like "*" & [forms]![Frmzoeken]![txtselectiecode] & "*"
) OR ((([Forms]![Frmzoeken]![txtselectiecode]) Is Null));
This all works great, i see the selection in the query, etc.
BUT:
I want to have a button on my form that opens outlook XP with all the addresses in BCC and my address in TO
I've tried this code i found here:
Private Sub Command0_Click()
Dim MyEmailList As String
MyEmailList = ColumnToLine("Qryfrmzoeken", "Email"
DoCmd.SendObject , , , "me@me.nl", , MyEmailList, "Test Message", , True
End Sub
Copy the following code into a new module for the above to work
Public Function ColumnToLine(TblQueryName, ColumnName)
On Error GoTo ErrInFunction
Dim myRs As DAO.Recordset
Dim ResultString As String
Set myRs = CurrentDb.OpenRecordset(TblQueryName)
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
This code works great without my selection, but with it doesn't work
I hope somebody can help me, because i am realy missing something but i don't see it anymore
Thanks
This is driving me MAD!!!, I have read hundreds of topics in this forum and still Ican't get it to work
I Want to sent a e-mail to adresses from a query using a selection on a form. I have a lot of names
in a table and each name has one or more selection codes (like: school or theater). In a form (Frmzoeken) i have a listbox with the selection codes in it
, so when i select school i see all the schools on a subform in a query (Qryfrmzoeken):
SELECT TblAdressen.AdresID, TblAdressen.Naam, TblAdressen.BezoekStraat, TblAdressen.BezoekPostcode, TblAdressen.BezoekPlaats, TblAdressen.PostStraat, TblAdressen.PostPostcode, TblAdressen.Postplaats, TblAdressen.Email, TblAdressen.Selectiecode, TblAdressen.Trefwoorden
FROM TblAdressen
WHERE (((TblAdressen.Selectiecode) Like "*" & [forms]![Frmzoeken]![txtselectiecode] & "*"
This all works great, i see the selection in the query, etc.
BUT:
I want to have a button on my form that opens outlook XP with all the addresses in BCC and my address in TO
I've tried this code i found here:
Private Sub Command0_Click()
Dim MyEmailList As String
MyEmailList = ColumnToLine("Qryfrmzoeken", "Email"
DoCmd.SendObject , , , "me@me.nl", , MyEmailList, "Test Message", , True
End Sub
Copy the following code into a new module for the above to work
Public Function ColumnToLine(TblQueryName, ColumnName)
On Error GoTo ErrInFunction
Dim myRs As DAO.Recordset
Dim ResultString As String
Set myRs = CurrentDb.OpenRecordset(TblQueryName)
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
This code works great without my selection, but with it doesn't work
I hope somebody can help me, because i am realy missing something but i don't see it anymore
Thanks