ah fixed
Code:
'email stored for the TO email field
Function CombineEmails(strEmail1Pull As Variant, strEmail2Pull As Variant) As String
Dim strEmail1 As String
Dim strEmail2 As String
strEmail1 = IIf(IsNothing(strEmail1Pull), " ", strEmail1Pull)
strEmail2 = IIf(IsNothing(strEmail2Pull), " ", strEmail2Pull)
'if both exist and are the same then combine into one line using ;
If Not IsNull(strEmail1) And Not IsNull(strEmail2) Then
If strEmail1 = strEmail2 Then
CombineEmails = strEmail1
Else
CombineEmails = strEmail1 & ";" & strEmail2
End If
'if the first email exists but the second one is null then email only the first
ElseIf Not IsNull(strEmail1) And IsNull(strEmail2) Then
CombineEmails = strEmail1
'if the first doesn't exist and the second one does then email the second
ElseIf IsNull(strEmail1) And Not IsNull(strEmail2) Then
CombineEmails = strEmail2
'and if both are blank give message
ElseIf IsNull(strEmail1) And IsNull(strEmail2) Then
MsgBox "Note you have no email on this booking, you can still email this however no email will be there to email!"
CombineEmails = ""
End If
End Function