Mailto

Cool, so a few observations if you want.
You declare db and assign it CurrentDb, but you never actually use it, so we can remove that . . .
Code:
Private Sub Command20_Click()
    Dim stEmailRecips As String
    Dim stSubject As String
    Dim stSQL As String
    Dim Rs As DAO.Recordset

    stSQL = "SELECT Email FROM Invoices Query;"
    stEmailRecips = Me.Email
    stSubject = ("New Invoice Added")
    DoCmd.SendObject acSendNoObject, , , stEmailRecips, , , stSubject, "A new invoice has been created at RGRoofing.UK please click here http://www.RGRoofing.uk"
End Sub
Simillarly, you never use rs, or stSQL, so we refactor some more . . .
Code:
Private Sub Command20_Click()
    Dim stEmailRecips As String
    Dim stSubject As String

    stEmailRecips = Me.Email
    stSubject = ("New Invoice Added")
    DoCmd.SendObject acSendNoObject, , , stEmailRecips, , , stSubject, "A new invoice has been created at RGRoofing.UK please click here http://www.RGRoofing.uk"
End Sub
stEmailRecips, you declare, assign a value, and use, but we can tighten that up by using Me.Email directly . . .
Code:
Private Sub Command20_Click()
    Dim stSubject As String

    stSubject = ("New Invoice Added")
    DoCmd.SendObject acSendNoObject, , , Me.Email, , , stSubject, "A new invoice has been created at RGRoofing.UK please click here http://www.RGRoofing.uk"
End Sub
. . . and the same thing with stSubject . . .
Code:
Private Sub Command20_Click()
    DoCmd.SendObject acSendNoObject, , , Me.Email, , , "New Invoice Added", "A new invoice has been created at RGRoofing.UK please click here http://www.RGRoofing.uk"
End Sub
. . . and finally, we can add a line continuation character, so we can see the whole line . . .
Code:
Private Sub Command20_Click()
    DoCmd.SendObject acSendNoObject, , , Me.Email, , , "New Invoice Added", _
        "A new invoice has been created at RGRoofing.UK please click here http://www.RGRoofing.uk"
End Sub
So we've reduced it to it's bare essentials. Everything has a distinct purpose, and there is no wasted code. Do you see what happened there?
 

Users who are viewing this thread

Back
Top Bottom