F
faberk
I am trying to set clear the contents of a textbox and set the focus back to
it if a condition exists. It clears the box, but icant set the focus back to
it. What am i doing wrong?
Private Sub txtEmpNo_Exit(Cancel As Integer)
Dim strEmpNo As String
On Error GoTo txtEmpNo_Exit_Error
strEmpNo = Me.txtEmpNo.Text
If IsNull(DLookup("[empno]", "tblEmployee", "[empno] = '" & strEmpNo &
"'")) Then
MsgBox "Not a valid employee number", vbInformation, "Info"
Me.txtEmpNo.Text = ""
Me.txtEmpNnDirty = False
Me.txtEmpNo.SetFocus
Else
lblEmpName.Caption = DLookup("[emplname]", "tblEmployee", "[empno] =
'" & strEmpNo & "'")
End If
On Error GoTo 0
Exit Sub
txtEmpNo_Exit_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
txtEmpNo_Exit of VBA Document Form_frmTimekeeping"
End Sub
it if a condition exists. It clears the box, but icant set the focus back to
it. What am i doing wrong?
Private Sub txtEmpNo_Exit(Cancel As Integer)
Dim strEmpNo As String
On Error GoTo txtEmpNo_Exit_Error
strEmpNo = Me.txtEmpNo.Text
If IsNull(DLookup("[empno]", "tblEmployee", "[empno] = '" & strEmpNo &
"'")) Then
MsgBox "Not a valid employee number", vbInformation, "Info"
Me.txtEmpNo.Text = ""
Me.txtEmpNnDirty = False
Me.txtEmpNo.SetFocus
Else
lblEmpName.Caption = DLookup("[emplname]", "tblEmployee", "[empno] =
'" & strEmpNo & "'")
End If
On Error GoTo 0
Exit Sub
txtEmpNo_Exit_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
txtEmpNo_Exit of VBA Document Form_frmTimekeeping"
End Sub