Set Focus Not working on a form

S

starke1120

I have a form that onlost focus of txtBadgID executes the following
code:

Private Sub txtBadgeID_AfterUpdate()

strEmpID = DLookup("[id]", "tblEmployee", "[BadgeID] =
forms!frmSave!checkedoutby")
If IsNull(strEmpID) Then
MsgBox "Badge Not Found, Enter Employee then Proceed!",
vbCritical, "Equipment Check Out"
Me.txtBadgeID.Value = ""
Me.txtBadgeID.SetFocus
Exit Sub
End If
Me.Employee_ID.Value = strEmpID
Me.Equipment_ID.Value = Forms!frmScanLocation.txtEquipmentID
Me.CheckedOut.Value = True
DoCmd.Close
Forms!frmScanLocation.Visible = True
Forms!frmScanLocation.txtScanLoc.Value = ""

End Sub

My problem is that txtBadgID is not gaining focus if strEmpID isNull
(the first if Statement. Any Ideas? It then line
me.txtBadgeID.Setfocus should work... The line me.txtBadgeID.Value = ""
does in face clear the text box from all text.. Any thoughts?

Thanks,

Dave
 
S

starke1120

I followed this instructions and it worked. the msgbox was coming up
but the set focus wasnt working

found the fix at this post..
http://groups.google.com/group/micr...Not+working+on+a+form&rnum=4#c8ab1e7b475573d3

Thanks,

Dave

Sorry, change
If isnull(strEmpID) then to
If strEmpID="" then
Alok

I have a form that onlost focus of txtBadgID executes the following
code:

Private Sub txtBadgeID_AfterUpdate()

strEmpID = DLookup("[id]", "tblEmployee", "[BadgeID] =
forms!frmSave!checkedoutby")
If IsNull(strEmpID) Then
MsgBox "Badge Not Found, Enter Employee then Proceed!",
vbCritical, "Equipment Check Out"
Me.txtBadgeID.Value = ""
Me.txtBadgeID.SetFocus
Exit Sub
End If
Me.Employee_ID.Value = strEmpID
Me.Equipment_ID.Value = Forms!frmScanLocation.txtEquipmentID
Me.CheckedOut.Value = True
DoCmd.Close
Forms!frmScanLocation.Visible = True
Forms!frmScanLocation.txtScanLoc.Value = ""

End Sub

My problem is that txtBadgID is not gaining focus if strEmpID isNull
(the first if Statement. Any Ideas? It then line
me.txtBadgeID.Setfocus should work... The line me.txtBadgeID.Value = ""
does in face clear the text box from all text.. Any thoughts?

Thanks,

Dave
 
Top