I am working on a database that if the user selects "Other" for certain fields, a text box then becomes visible. At that point, the newly visible field becomes required. I am having problems returning focus to that field. I enter the control and do not enter any text, but tab out of it. My code runs fine, with message displaying, but the next control on the tab order is still getting the focus. I have tried placing this code in every imaginable place (BeforeUpdate, etc) with no luck. Here is the code.
Private Sub txtOtherPOB_LostFocus()
'If user does not enter value, send message and set focus.
If txtOtherPOB.Text = "" Then 'Other not typed in
If PlaceOfBirth.Value = "Q" Then 'Other selected
MsgBox "Other Place of Birth must be entered"
txtOtherPOB.SetFocus
Exit Sub
End If
Else
Exit Sub
End If
End Sub
Any help would be greatly appreciated!
Thanks!
Private Sub txtOtherPOB_LostFocus()
'If user does not enter value, send message and set focus.
If txtOtherPOB.Text = "" Then 'Other not typed in
If PlaceOfBirth.Value = "Q" Then 'Other selected
MsgBox "Other Place of Birth must be entered"
txtOtherPOB.SetFocus
Exit Sub
End If
Else
Exit Sub
End If
End Sub
Any help would be greatly appreciated!
Thanks!