Email from a continuous form (1 Viewer)

sroot

Registered User.
Local time
Today, 08:07
Joined
Mar 18, 2013
Messages
53
Hi guys. I have a database that pulls information from a query puts it in a form and then emails it to whoever needs it. everything works fine on it except i cannot get it to work with a continuous form. it only emails the top row. I cant figure out what to do to make it pull all the records. Any idea what i need to do? I think i might need to do some type of loop but not sure and not sure how. I am pretty new to this still so if anyone could help that would be great.

Code:
Private Sub Command4_Click()
On Error GoTo Err_SendInfo_Click

    Dim varTo As Variant
    Dim varCC As Variant
    Dim stSubject As String
    Dim stItem As String
    Dim stQty As String

    varTo = DLookup("[Email]", "tblEmail")
    varCC = DLookup("[CC]", "tblEmail")
    stSubject = "Items to fix"
    stItem = Me.item
    stQty = Me.qty
        
    stText = "*****DO NOT EDIT ANYTHING*****." & Chr$(13) & Chr$(13) & _
             "Item: " & stItem & Chr$(13) & _
             "Qty: " & stQty
            
  
    DoCmd.SendObject , , acFormatTXT, varTo, varCC, , stSubject, stText, -1
    
    On Error GoTo Err_Execute
    CurrentDb.Execute strSQL, dbFailOnError
    On Error GoTo 0

     Exit Sub

Err_Execute:
    Resume Next
Exit_SendInfo_Click:
    Exit Sub
Err_SendInfo_Click:
    MsgBox Err.Description
    Resume Exit_SendInfo_Click

End Sub
 

essaytee

Need a good one-liner.
Local time
Tomorrow, 01:07
Joined
Oct 20, 2008
Messages
512
I can't provide exact code at the moment but your approach could be along these lines:

1. Create a Recordset based on the RecordsetClone of your form (Set rst = Me.RecordSetClone)

2. Move to the first record
3. Apply your email routine (based on info in Recordset)
4. Loop to next record (whilst not End of File)
5. Close Recordset

Steve.
 

sroot

Registered User.
Local time
Today, 08:07
Joined
Mar 18, 2013
Messages
53
That's pretty much the same thing i keep coming across in researching, the problem is i don't know how to make it work in my code.
 

Users who are viewing this thread

Top Bottom