Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rst.MoveNext

Status
Not open for further replies.

raa44634

Technical User
Dec 13, 2001
34
US
The code below is processing report and then emailing automatically as defined in a table tbl_Email.

The first entry in the tbl_Email is executing correctly. Subsequent entries are emailing but are processing under the first entry's parameters. It appears my rst.MoveNext isn't working as it should.

Any ideas why?

Thanks!
- Tony -



Private Sub cmdEmail_Click()

Dim rst As DAO.Recordset
Dim dbs As DAO.Database
Dim subject As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tbl_Email", dbOpenForwardOnly)

Do Until rst.EOF = True

Dim msgtxt As String
Dim txtdate As String
subject = "Labor Distribution Report"
txtdate = Now()
msgtxt = "***AUTOMATED DISTRIBUTION***" & vbCrLf & vbCrLf & "Report ran at " + txtdate + "." & vbCrLf & vbCrLf & _
"Parameter Definition String: PSID...Division...Entity (G1)...Location (G2)...Department (G3)" & vbCrLf & vbCrLf & _
"The attached report's parameters are: " & _
vbCrLf & vbCrLf & rst!PsidL & "..." & rst!DCL & "..." & rst!G1L & "..." & rst!G2L & "..." & rst!G3L & vbCrLf _
& vbCrLf & rst!PsidH & "..." & rst!DCH & "..." & rst!G1H & "..." & rst!G2H & "..." & rst!G3H

DoCmd.SendObject acSendReport, rst!RptName, rst!Output, rst!EmailName, , , subject, msgtxt, False

rst.MoveNext

Loop

rst.Close
dbs.Close
Set rst = Nothing
Set dbs = Nothing


End Sub
 
Try putting rst.MoveFirst just before the
Do Until rst.EOF = True Line.

Cheers

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top