Wrathchild
Technical User
Instead of using the validation on the field's properties, I'm trying to write code. The validation is no problem, it's what happens after...the focus will go to the next item in the tab order. I'm trying to stop it from leaving the field until the validation is satisfied, but can't seem to get it. Below is what I have (it's on a subform); I've tried it on AfterUpdate, LostFocus, and On Exit with no luck. I know the setfocus code works because I use it in a different instance on a form open, it just won't work here.
Private Sub num_dy_wrkwk_AfterUpdate()
If Me.num_dy_wrkwk > 7 Or Me.num_dy_wrkwk < 1 Then
MsgBox "Please enter a number between 1 and 7.", vbOKOnly, "INCORRECT ENTRY"
Forms!switchboard!Window2.SetFocus
Forms!switchboard!Window2.Form![num_dy_wrkwk].SetFocus
End If
End Sub
Private Sub num_dy_wrkwk_AfterUpdate()
If Me.num_dy_wrkwk > 7 Or Me.num_dy_wrkwk < 1 Then
MsgBox "Please enter a number between 1 and 7.", vbOKOnly, "INCORRECT ENTRY"
Forms!switchboard!Window2.SetFocus
Forms!switchboard!Window2.Form![num_dy_wrkwk].SetFocus
End If
End Sub