Newman
Québécois
- Local time
- Today, 06:08
- Joined
- Aug 26, 2002
- Messages
- 766
I have a module that, every nights, opens a report and sends it by e-mail to the person the records belong to in a snapshot format. (Its code follows this message...)
It's been working fine for a couple of months, but started to act crazy last weekend.
Sometimes, it sends more snp files that it should. The customer receives the snp files that belongs to him and snp files that belong to someone else but from a different night.
ie: Last night, Mr.X got his snp file with his records from yesterday. That's fine!
But he also got snp files with records of last week from Mr.Y. That's not fine at all!
Do any of you have an idea where the problem could come from?
Many thanks!
The query «qRequestAcceptance», which is used for the recordset and the report, is the list of all the records where [RequestDate] = Date()-1.
It's been working fine for a couple of months, but started to act crazy last weekend.
Sometimes, it sends more snp files that it should. The customer receives the snp files that belongs to him and snp files that belong to someone else but from a different night.
ie: Last night, Mr.X got his snp file with his records from yesterday. That's fine!
But he also got snp files with records of last week from Mr.Y. That's not fine at all!
Do any of you have an idea where the problem could come from?
Many thanks!
Code:
Public Sub SendRequestAcceptance()
Dim DB As Connection
Dim rsRequestAcceptance As New ADODB.Recordset
stDocName = "repRequestAcceptance"
Set DB = CurrentProject.Connection
With rsRequestAcceptance
.Open "SELECT DISTINCT MailAddress FROM qRequestAcceptance", DB, adopenstatic, adlockoptimistic
If .RecordCount = 0 Then Exit Sub
.MoveFirst
Do Until .EOF
stMailAddress = rsRequest.Fields(0)
DoCmd.OpenReport stDocName, acViewDesign
Report_repRequestAcceptance.Filter = "[MailAddress]='" & stMailAddress & "'"
DoCmd.SendObject acSendReport, stDocName, acFormatSNP, stMailAddress, , , "RequestAcceptance","RequestAcceptance" , False
DoCmd.Close acReport, stDocName, acSaveNo
.MoveNext
Loop
.Close
DB.Close
End With
End Sub
Last edited: