when invoice sent tick the sent box automatically

rainbows

Registered User.
Local time
Yesterday, 21:37
Joined
Apr 21, 2017
Messages
428
Code:
Private Sub cmdEmail_Click()

On Error GoTo Err_Handler


    Dim strTo As String
    Dim strSubject As String
    Dim strMessageText As String
    
    
     If IsNull(Me.[E-Mail address]) Then
     MsgBox "No email address in customer form"

    Exit Sub
    
 Else
 
 
    Me.Dirty = False
     Me.addressno = InputBox("Please provide address line number")
    
    strTo = Me.[E-Mail address]
    strSubject = "Invoice Number " & Me.[Invoice].[Form]![InvoiceNo]
    strMessageText = Me.[Firstname] & "," & _
        vbNewLine & vbNewLine & _
        "Your latest invoice is attached." & _
        vbNewLine & vbNewLine & _
        ""


    DoCmd.SendObject ObjectType:=acSendReport, _
        ObjectName:="Invoice report", _
        OutputFormat:=acFormatPDF, _
        TO:=strTo, _
        Subject:=strSubject, _
        messageText:=strMessageText, _
        EditMessage:=True
Exit_Here:
   End If

    Exit Sub
Err_Handler:
    MsgBox Err.Description
    Resume Exit_Here

    

End Sub



this is the code i use to send an invoice to the customer , if possible i would like it to tick the "sent invoice" tick box. within this code . the form is called invoices

thanks for you help

1660979586099.png
 

Attachments

  • 1660979481803.png
    1660979481803.png
    228.1 KB · Views: 139
No guarantee that it will be sent though is there?
You open the email with that code, what if I just click the Close icon?
 
that is true , i just thought they would send it if they pressed the " e.mail invoice" button or maybe if the ticked that box it would send it ?
 
Well you could send it direct, at least then it would go to the Outbox, but could still not be actually sent, generated Yes.
That will only work if the user does not need to edit the email?

Code would likely be along the lines of
Forms!Invoice.chkEmailSent = True

where chkEmailSent is the name of your checkbox control. (Untested though)
 
Personally I would use a date rather than a tickbox - more information- can still be displayed as a checkbox if you require
 
thank you

this is what worked
Code:
 Me.[Invoice].[Form]![Invoice sent] = True
 
No guarantee that it will be sent though is there?
You open the email with that code, what if I just click the Close icon?
If you don't send the mail., Error 2501 will occur.
By trapping this error code, you/OP can be assured the mail has been sent or not.
 
Why not just Me.[Invoice sent] = True
 
1660992512407.png

Why not just Me.[Invoice sent] = True. this error came up when i used that
 
So Invoice is actually a subform?
 
I would store it as a date field in the table, and if I wanted a CheckBox indicator I would assign it a value like...
Code:
Me.chkInvoiceSent = IsDate(Me.InvoiceSentDate)
 
I would store it as a date field in the table, and if I wanted a CheckBox indicator I would assign it a value like...
Code:
Me.chkInvoiceSent = IsDate(Me.InvoiceSentDate)
@rainbows Adjust that to suit your form structure
 

Users who are viewing this thread

Back
Top Bottom