Hi everyone
I have a textbox where the user enters a value. This value is them compared to a table in an afterupdate event and if the same value already exists, then it returns and error message and it requests that a new value is entered.
It works fine until the last bit of code. The problem comes when I try to get the focus back to the box by using "Me.txtSKu.setfocus". It just does not do it. No matter what i try, the focus always goes to the next textbox.
Why? What am I missing?
Thanks
mafhobb
I have a textbox where the user enters a value. This value is them compared to a table in an afterupdate event and if the same value already exists, then it returns and error message and it requests that a new value is entered.
Code:
Private Sub txtSKU_AfterUpdate()
Dim UserCount As Long
Dim TestedSKU As String
' Check to see if text was entered
Me.txtSKU.SetFocus
If Me.txtSKU.Text = "" Then
MsgBox "Please enter a SKU#"
Exit Sub
End If
'if text was entered, assign the SKU value to a variable
TestedSKU = Me.txtSKU.Value
'Check to see if the SKU# already exists
UserCount = DCount("[SKU#]", "[TblSKUMessage]", "[SKU#] = '" & TestedSKU & "'")
If UserCount > 0 Then
MsgBox "This SKU# already exists. You cannot have two messages for the same SKU#. Please find and modify the existing SKU# message."
Me.txtSKU.SetFocus
Exit Sub
End If
End Sub
It works fine until the last bit of code. The problem comes when I try to get the focus back to the box by using "Me.txtSKu.setfocus". It just does not do it. No matter what i try, the focus always goes to the next textbox.
Why? What am I missing?
Thanks
mafhobb