List all records

S

SandySun

Does anyone know how to loop records so that I can list the "Interim
Immediate" for every "dl" code without hard coding each record. Thanks!
See below for code.

Function SendByEmail(strtest As String, strEmail As String) As Boolean
On Error GoTo PROC_ERR
Dim strRecipient As String
Dim strSubject As String
Dim strMessageBody As Variant
strRecipient = strEmail
strSubject = "Auto Reports " & Format(DLookup("DateOccurred",
"Balance", "dl= 962"), "mm\/dd\/yyyy")
strMessageBody = Format(Nz(DLookup("DateOccurred", "Balance", "dl=
962"), "Auto Information Is Unavailable At This Time"), "mm\/dd\/yyyy") &
vbCrLf & _
"" & vbCrLf & _
"------------- " + vbCrLf & _
"Interim Immediate " & Format(DLookup("amountround", "Balance", "dl=
962"), "$#,###") + vbCrLf & _
"------------- " + vbCrLf & _
"Total Avail. " & Format(DSum("amountround", "Balance"), "$#,###") & _
DoCmd.SendObject , , , strRecipient, , , strSubject,
strMessageBody, False
SendByEmail = True
PROC_EXIT:
Exit Function
PROC_ERR:
SendByEmail = False
If Err.Number = 2501 Then
Call MsgBox( _
"The email was not sent for " & strEmail & ".", _
vbOKOnly + vbExclamation + vbDefaultButton1, _
"User Cancelled Operation")
Else
MsgBox Err.description
End If
Resume PROC_EXIT
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top