S
Stephanie
Hi. I'm having a problem in my function getting the correct msg box to
appear. One of the discussion group members suggested using:
If Like2(strZip, "@#@#@#") Then
No idea what Like2 is. I'd appreciate any insight as to why my code isn't
functioning correctly. Thanks so much!
Private Sub PostalCode1_LostFocus()
If Not VBA.IsNull(Me.PostalCode1.Value) Then
strZip = Me.PostalCode1.Value
CheckMailCodeFormat
End If
End Sub
Function CheckMailCodeFormat()
Select Case Len(strZip)
Case 5
'5-Digit US StrZip code
If Not strZip Like "#####" Then
MsgBox "'" & strZip & "' is not a valid 5-digit US Zip code."
Me.PostalCode1.Value = Null
End If
Case 6
'Canadian postal code (without space)
'If Like2(strZip, "@#@#@#") Then
If strZip Like "@#@#@#" Then
Me.PostalCode1.Value = UCase(Format(strZip, "@@@ @@@"))
Else
MsgBox "'" & strZip & "' is not a valid Canadian postal code."
Me.PostalCode1.Value = Null
End If
Case 7
appear. One of the discussion group members suggested using:
If Like2(strZip, "@#@#@#") Then
No idea what Like2 is. I'd appreciate any insight as to why my code isn't
functioning correctly. Thanks so much!
Private Sub PostalCode1_LostFocus()
If Not VBA.IsNull(Me.PostalCode1.Value) Then
strZip = Me.PostalCode1.Value
CheckMailCodeFormat
End If
End Sub
Function CheckMailCodeFormat()
Select Case Len(strZip)
Case 5
'5-Digit US StrZip code
If Not strZip Like "#####" Then
MsgBox "'" & strZip & "' is not a valid 5-digit US Zip code."
Me.PostalCode1.Value = Null
End If
Case 6
'Canadian postal code (without space)
'If Like2(strZip, "@#@#@#") Then
If strZip Like "@#@#@#" Then
Me.PostalCode1.Value = UCase(Format(strZip, "@@@ @@@"))
Else
MsgBox "'" & strZip & "' is not a valid Canadian postal code."
Me.PostalCode1.Value = Null
End If
Case 7