I have a code that is based on a query. Basically when I press the reports button, it is supposed to start with the first record, open the report based on the store number that's in the first column, and then send that in a pdf file. It's then supposed to move on to the next record and repeat the process. When I run it however, it sends the correct number of emails, but the information never seems to change from the first record, so it sends based on the email address and store number of what is in the first record. My code is below.
Code:
Private Sub Reports_Click()
Dim MyDB As DAO.Database, RS As DAO.Recordset
Dim Email As String
Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set RS = MyDB.OpenRecordset _
("CMR Submits")
RS.MoveLast
RS.MoveFirst
Do Until RS.EOF
Email = Me.Email
DoCmd.OpenReport "CMR Submit Store Report", acViewReport, , "[Store]=" & Me.Store__ & ""
DoCmd.SendObject acSendReport, "CMR Submit Store Report", acFormatPDF, Email, , , "CMR Reports", , True
RS.MoveNext
Loop
RS.Close
MyDB.Close
Set RS = Nothing
Set MyDB = Nothing
Close
End Sub