Hello everybody, I am trying to create a form that sends mail alerts with a filtered report for each person. I have been using some code I found online.
This is my problem, right now it is sending the mails and it is filtering the report but only filter the same records, after the first mail the rest of the mails have the exact same report (filtered but not the right filter)
I would appreciate any help on this.
I created a blank form with a button and this code:
Private Sub Command2_Click()
Dim RS As DAO.Recordset
Set RS = CurrentDb.OpenRecordset("mail_Reminder_RecordSet")
With RS
If .EOF And .bof Then 'IT MEANS THERE ARE NO RECORDS, WE ARE AT THE BEGINNING OF FILE AND END OF FILE (No Records found for this query.)
Else
Do Until .EOF 'DO UNTIL END OF RECORDSET FILE
DoCmd.SendObject acSendReport, "report", acFormatPDF, ![mailadress], , , "Low Balance Alert", "Hello " & ![FirstName] & _
", " & Chr(10) & "You ballance is under 10 pounds. Please…", False
.Edit
![mail_Sent_Date] = Now()
.Update
.MoveNext
Loop
End If
End With
'CLEAN UP MEMORY AT END
If Not RS Is Nothing Then
RS.Close
Set RS = Nothing
End If
End Sub
Then I have this code under "On Open" in the report:
Private Sub Report_Open(Cancel As Integer)
Me.Filter = "IncidKey = '" & Forms![Menu]![IncidKey] & "'"
Me.FilterOn = True
End Sub
Any Ideas? Thanks a lot
This is my problem, right now it is sending the mails and it is filtering the report but only filter the same records, after the first mail the rest of the mails have the exact same report (filtered but not the right filter)
I would appreciate any help on this.
I created a blank form with a button and this code:
Private Sub Command2_Click()
Dim RS As DAO.Recordset
Set RS = CurrentDb.OpenRecordset("mail_Reminder_RecordSet")
With RS
If .EOF And .bof Then 'IT MEANS THERE ARE NO RECORDS, WE ARE AT THE BEGINNING OF FILE AND END OF FILE (No Records found for this query.)
Else
Do Until .EOF 'DO UNTIL END OF RECORDSET FILE
DoCmd.SendObject acSendReport, "report", acFormatPDF, ![mailadress], , , "Low Balance Alert", "Hello " & ![FirstName] & _
", " & Chr(10) & "You ballance is under 10 pounds. Please…", False
.Edit
![mail_Sent_Date] = Now()
.Update
.MoveNext
Loop
End If
End With
'CLEAN UP MEMORY AT END
If Not RS Is Nothing Then
RS.Close
Set RS = Nothing
End If
End Sub
Then I have this code under "On Open" in the report:
Private Sub Report_Open(Cancel As Integer)
Me.Filter = "IncidKey = '" & Forms![Menu]![IncidKey] & "'"
Me.FilterOn = True
End Sub
Any Ideas? Thanks a lot