Access 2007 Runtime Error 2108 SetFocus

Joined
Feb 21, 2009
Messages
1
Reaction score
0
When I use the following code, I get a Runtime Error 2108:

Private Sub Phone_BeforeUpdate(Cancel As Integer)
'verify the first three digits of VA phones
Dim phFirstThree As Integer
If Not IsNull([State]) And Not IsNull([Phone]) Then
phFirstThree = Val(Left(Phone, 3))
Select Case State
Case "VA"
If phFirstThree <> 703 And phFirstThree <> 804 Then
DoCmd.CancelEvent
MsgBox "VA phone numbers must have an area code of 703 or 804"
Me.Undo
Phone.SetFocus
End If
End Select
End If
End Sub

However, If I remark out (or delete) the "Phone.SetFocus" line, the code works. Other people have tried my database using this code without problem.

Any ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top