when invoice sent tick the sent box automatically (1 Viewer)

rainbows

Registered User.
Local time
Today, 01:29
Joined
Apr 21, 2017
Messages
425
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: 87

Gasman

Enthusiastic Amateur
Local time
Today, 09:29
Joined
Sep 21, 2011
Messages
14,319
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?
 

rainbows

Registered User.
Local time
Today, 01:29
Joined
Apr 21, 2017
Messages
425
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 ?
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:29
Joined
Sep 21, 2011
Messages
14,319
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)
 

CJ_London

Super Moderator
Staff member
Local time
Today, 09:29
Joined
Feb 19, 2013
Messages
16,619
Personally I would use a date rather than a tickbox - more information- can still be displayed as a checkbox if you require
 

rainbows

Registered User.
Local time
Today, 01:29
Joined
Apr 21, 2017
Messages
425
thank you

this is what worked
Code:
 Me.[Invoice].[Form]![Invoice sent] = True
 

KitaYama

Well-known member
Local time
Today, 17:29
Joined
Jan 6, 2022
Messages
1,541
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.
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:29
Joined
Sep 21, 2011
Messages
14,319
Why not just Me.[Invoice sent] = True
 

rainbows

Registered User.
Local time
Today, 01:29
Joined
Apr 21, 2017
Messages
425
1660992512407.png

Why not just Me.[Invoice sent] = True. this error came up when i used that
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:29
Joined
Sep 21, 2011
Messages
14,319
So Invoice is actually a subform?
 

MarkK

bit cruncher
Local time
Today, 01:29
Joined
Mar 17, 2004
Messages
8,183
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)
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:29
Joined
Sep 21, 2011
Messages
14,319
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

Top Bottom