By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,027 Members | 1,313 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,027 IT Pros & Developers. It's quick & easy.

Auto E-mail

P: 1
I have a simple database created which requires an Auto E-mail to be sent to individuals who are 30 days pass due. The following code works fine for the first record but doesn't step in and do the same with other records, as well, the Do While (expression) and Loop sends the e-mail to the first record ... could someone tell me what I need to do ...

Private Sub Form_Load()
Dim emailaddr As String
emailaddr = Me.Champion

If [30 Day Expiry] = Date Then

Do While whatever condition
DoCmd.SendObject , _
, , emailaddr, , , "Report One", "Hello", False
Loop
Dec 20 '06 #1
Share this Question
Share on Google+
1 Reply


MMcCarthy
Expert Mod 10K+
P: 14,534
You need a recordset to loop through. Assuming all records are on the current form you can use.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open()
  2. Dim rs As DAO.Recordset
  3.  
  4.    Set rs = Me.RecordsetClone
  5.  
  6.    rs.MoveFirst
  7.    Do Until rs.EOF
  8.       If Me.[30 Day Expiry] = Date Then
  9.          DoCmd.SendObject , , , rs!Champion, , , "Report One", "Hello", False
  10.       End If
  11.       rs.MoveNext
  12.    Loop
  13.  
  14. End Sub
  15.  
Mary
Dec 21 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.