Auto E-mail

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PaperClip
    New Member
    • Dec 2006
    • 1

    #1

    Auto E-mail

    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.SendObjec t , _
    , , emailaddr, , , "Report One", "Hello", False
    Loop
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    You need a recordset to loop through. Assuming all records are on the current form you can use.

    Code:
    Private Sub Form_Open()
    Dim rs As DAO.Recordset
    
       Set rs = Me.RecordsetClone
    
       rs.MoveFirst
       Do Until rs.EOF
    	  If Me.[30 Day Expiry] = Date Then
    		 DoCmd.SendObject , , , rs!Champion, , , "Report One", "Hello", False
    	  End If
    	  rs.MoveNext
       Loop
    
    End Sub
    Mary

    Comment

    Working...