Thanks for replying
I am probably making this too complicated for myself :-(
The .value was a mistake after I used the code I was trying a lot of methods.
I need the boxes to change when I click submit there is a lot more code that will go with the code in question
I have a box to count the null values to pop up before I send the invoice to customers
the current code is below if you see I have the same type of code repeating which works however I will be tripling the amount of textboxes so need a way to lower the code
Code:
Private Sub Command85_Click()
'On Error GoTo er2:
Set db = Nothing
Dim myPath As String
Dim strReportName As String
Dim strReport1, strReport2 As String
Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem
Dim MyBodyText As String
Dim Attach, Attach2 As String
lngRed = RGB(255, 0, 0)
lngRed2 = background1
Forms!Home.Job_List_and_invoice.Form.[NumberBox1].Value = 0
'----------------[Text25]
If IsNull(Forms!Home.Job_List_and_invoice.Form.[Text25].Value) Then
Forms!Home.Job_List_and_invoice.Form.[Text25].BorderColor = lngRed
Forms!Home.Job_List_and_invoice.Form.[Text25].BorderWidth = 2
Forms!Home.Job_List_and_invoice.Form.[NumberBox1].Value = Forms!Home.Job_List_and_invoice.Form.[NumberBox1].Value + 1
Else
Forms!Home.Job_List_and_invoice.Form.[Text25].BorderColor = lngRed2
Forms!Home.Job_List_and_invoice.Form.[Text25].BorderWidth = Hairline
End If
'----------------[Total Cost]
If Forms!Home.Job_List_and_invoice.Form.[Total Cost].Value = 0 Then
Forms!Home.Job_List_and_invoice.Form.[Total Cost].BorderColor = lngRed
Forms!Home.Job_List_and_invoice.Form.[Total Cost].BorderWidth = 2
Forms!Home.Job_List_and_invoice.Form.[NumberBox1].Value = Forms!Home.Job_List_and_invoice.Form.[NumberBox1].Value + 1
Else
Forms!Home.Job_List_and_invoice.Form.[Total Cost].BorderColor = lngRed2
Forms!Home.Job_List_and_invoice.Form.[Total Cost].BorderWidth = Hairline
End If
'----------------[Job Specs]
If IsNull(Forms!Home.Job_List_and_invoice.Form.[Job Specs].Value) Then
Forms!Home.Job_List_and_invoice.Form.[Job Specs].BorderColor = lngRed
Forms!Home.Job_List_and_invoice.Form.[Job Specs].BorderWidth = 2
Forms!Home.Job_List_and_invoice.Form.[NumberBox1].Value = Forms!Home.Job_List_and_invoice.Form.[NumberBox1].Value + 1
Else
Forms!Home.Job_List_and_invoice.Form.[Job Specs].BorderColor = lngRed2
Forms!Home.Job_List_and_invoice.Form.[Job Specs].BorderWidth = Hairline
End If
'----------------[Customer Number]
If IsNull(Forms!Home.Job_List_and_invoice.Form.[Customer Number].Value) Then
Forms!Home.Job_List_and_invoice.Form.[Customer Number].BorderColor = lngRed
Forms!Home.Job_List_and_invoice.Form.[Customer Number].BorderWidth = 2
Forms!Home.Job_List_and_invoice.Form.[NumberBox1].Value = Forms!Home.Job_List_and_invoice.Form.[NumberBox1].Value + 1
Else
Forms!Home.Job_List_and_invoice.Form.[Customer Number].BorderColor = lngRed2
Forms!Home.Job_List_and_invoice.Form.[Customer Number].BorderWidth = Hairline
End If
'----------------[Combo85]
If IsNull(Forms!Home.Job_List_and_invoice.Form.[Combo85].Value) Then
Forms!Home.Job_List_and_invoice.Form.[Combo85].BorderColor = lngRed
Forms!Home.Job_List_and_invoice.Form.[Combo85].BorderWidth = 2
Forms!Home.Job_List_and_invoice.Form.[NumberBox1].Value = Forms!Home.Job_List_and_invoice.Form.[NumberBox1].Value + 1
Else
Forms!Home.Job_List_and_invoice.Form.[Combo85].BorderColor = lngRed2
Forms!Home.Job_List_and_invoice.Form.[Combo85].BorderWidth = Hairline
End If
If Forms!Home.Job_List_and_invoice.Form.[NumberBox1].Value <> 0 Then
MsgBox _
" Please input required Fields to complet this step" & vbNewLine & _
Chr(9) & " -------Or--------" & vbNewLine & _
Chr(9) & "Move Back to select inputted data", vbOKOnly
Exit Sub
Else
MsgBox "good to go"
End If
Exit Sub
er2:
If IsNull(Forms!Home.Job_List_and_invoice.Form.Reference.Value) And Not IsNull(Forms!Home.Job_List_and_invoice.Form.[Date Invoiced].Value) Then
refprt1 = Chr(WorksheetFunction.RandBetween(65, 90)) & Chr(WorksheetFunction.RandBetween(65, 90)) & Chr(WorksheetFunction.RandBetween(65, 90))
refprt2 = WorksheetFunction.RandBetween(100000, 999999)
Forms!Home.Job_List_and_invoice.Form.Reference.Value = refprt1 & refprt2
Exit Sub
End If
Exit Sub
DoCmd.OpenReport "Job List and invoice", acViewPreview
er:
myPath = "maypath"
strReport1 = Forms!Home.Job_List_and_invoice.Form.Reference.Value & "_"
strReport2 = Format(Forms!Home.Job_List_and_invoice.Form.[Date Invoiced].Value, "DD-MM-YY")
strReportName = "REF=" & strReport1 & Format(strReport2, "DD-MM-YY") & ".pdf"
On Error GoTo er:
DoCmd.OutputTo acOutputReport, "", acFormatPDF, myPath & strReportName
Attach = myPath & "REF=" & strReport1 & Format(strReport2, "DD-MM-YY") & ".pdf"
Set MyOutlook = New Outlook.Application
Set MyMail = MyOutlook.CreateItem(olMailItem)
With MyMail
.To = ""
.Subject = "Carpets Invoice Ref: " & strReport1
.Body = MyBodyText
.Attachments.Add Attach
.Display '.send
End With
Set MyMail = Nothing
'MyOutlook.Quit
Set MyOutlook = Nothing
'MailList.Close
Set MailList = Nothing
DoCmd.Close acReport, "Job List and invoice"
End Sub