I have a textbox on a userform which has the following trigger :
Private Sub txtLotId_AfterUpdate()
Lot_Id = frmMainForm.txtLotId.Text
If Lot_Id <> "" Then
SQLStmt = "SELECT POS,PIT FROM PIT_TABLE WHERE LOT = '" & Lot_Id & "'"
Set EmpDynaset = OraDatabase.DbCreateDynaset(SQLStmt, 0&)
PosName = EmpDynaset.Fields("Pos"
.Value
PitName = EmpDynaset.Fields("Pit"
.Value
If IsNull(PosName) Or IsNull(PitName) Then
Message = "Lot " & Lot_Id & " is not active!"
response = MsgBox(Message, vbOKOnly, "Lot ID Does Not Exist"
frmMainForm.lblMessage.Caption = Message
frmMainForm.txtLotId.Text = ""
frmMainForm.txtLotId.SetFocus
Exit Sub
End If
frmMainForm.lblPosName.Caption = PosName
frmMainForm.lblPitName.Caption = PitName
End If
End Sub
The problem is it DOES NOT set the focus back to the textbox but to the button beside it. I've googled this and tried the solution to no avail. Tried the Change event but this does not trigger when the textbox loses focus.
Can anyone offer me a solution ?
Thanks in advance.
Private Sub txtLotId_AfterUpdate()
Lot_Id = frmMainForm.txtLotId.Text
If Lot_Id <> "" Then
SQLStmt = "SELECT POS,PIT FROM PIT_TABLE WHERE LOT = '" & Lot_Id & "'"
Set EmpDynaset = OraDatabase.DbCreateDynaset(SQLStmt, 0&)
PosName = EmpDynaset.Fields("Pos"
PitName = EmpDynaset.Fields("Pit"
If IsNull(PosName) Or IsNull(PitName) Then
Message = "Lot " & Lot_Id & " is not active!"
response = MsgBox(Message, vbOKOnly, "Lot ID Does Not Exist"
frmMainForm.lblMessage.Caption = Message
frmMainForm.txtLotId.Text = ""
frmMainForm.txtLotId.SetFocus
Exit Sub
End If
frmMainForm.lblPosName.Caption = PosName
frmMainForm.lblPitName.Caption = PitName
End If
End Sub
The problem is it DOES NOT set the focus back to the textbox but to the button beside it. I've googled this and tried the solution to no avail. Tried the Change event but this does not trigger when the textbox loses focus.
Can anyone offer me a solution ?
Thanks in advance.