Hi All,
Can you see anything wrong with the below code? I'm trying to make sure that if the State in the record is VA, that the area code is either 703 or 804. When I test, no matter what I change the first 3 integers of the phone number to, I get the error msg box. Even if it's 703 or 804, I still get the error box. Any help would be appreciated. Thanks.
Can you see anything wrong with the below code? I'm trying to make sure that if the State in the record is VA, that the area code is either 703 or 804. When I test, no matter what I change the first 3 integers of the phone number to, I get the error msg box. Even if it's 703 or 804, I still get the error box. Any help would be appreciated. Thanks.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
'Verify the correct area code for VA
Dim AreaCode As Integer
If Not IsNull([State]) And Not IsNull([Phone]) Then
AreaCode = Val(Left([Phone], 3))
Select Case [State]
Case "VA"
If AreaCode <> "703" Or AreaCode <> "804" Then
DoCmd.CancelEvent
MsgBox "Area Code must be 703 or 804"
Phone.SetFocus
End If
End Select
End If
End Sub
Comment