Cheers Trevor,
I have input the code and adjusted to for my needs, however an error occurs when trying to run, stating "User defined error" referring to:
Private Sub CommandButton1_Click() and Dim olApp As Outlook.Application
This is what I have now:
Private Sub CommandButton1_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("PartsData")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for a part number
If Trim(Me.txtJobNo.Value) = "" Then
Me.txtJobNo.SetFocus
MsgBox "Please enter a job number"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.txtDate.Value
ws.Cells(iRow, 2).Value = Me.txtJobNo.Value
ws.Cells(iRow, 3).Value = Me.txtCusRef.Value
ws.Cells(iRow, 4).Value = Me.txtTOC.Value
ws.Cells(iRow, 5).Value = Me.txtTOB.Value
ws.Cells(iRow, 6).Value = Me.txtJourney.Value
ws.Cells(iRow, 7).Value = Me.txtIncident.Value
ws.Cells(iRow, 8).Value = Me.txtResolution.Value
ws.Cells(iRow, 9).Value = Me.cboType.Value
ws.Cells(iRow, 10).Value = Me.cboBy.Value
ws.Cells(iRow, 11).Value = Me.cboTo.Value
ws.Cells(iRow, 12).Value = Me.cboCus.Value
ws.Cells(iRow, 13).Value = Me.cboSup.Value
If Me.cboType = "T1" Then
Dim olApp As Outlook.Application
Dim olMail As MailItem
Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)
With olMail
.To = "
email@example.com"
.Subject = "T1 Case Raised"
.Body = txtJobNo.Value & vbCr & vbCr & _
.Display
'You can change this to .Send
'clear the data
Me.txtDate.Value = ""
Me.txtJobNo.Value = ""
Me.txtCusRef.Value = ""
Me.txtTOC.Value = ""
Me.txtTOB.Value = ""
Me.txtJourney.Value = ""
Me.txtIncident.Value = ""
Me.txtResolution.Value = ""
Me.cboType.Value = ""
Me.cboBy.Value = ""
Me.cboTo.Value = ""
Me.cboCus.Value = ""
Me.cboSup.Value = ""
Me.txtDate.SetFocus
End Sub