N
Nicholas Scarpinato
I have a problem with this code:
Private Sub Item_SKU_AfterUpdate()
....
....
Set db = CurrentDb
sql = "SELECT * FROM [Vendor Item Info]"
Set rs = db.OpenRecordset(sql)
With rs
.MoveLast
.MoveFirst
If IsNumeric(Forms![Returns Entry Form].[Item SKU]) = False Then
MsgBox "The SKU field must be numeric. Please re-enter the SKU."
Forms![Returns Entry Form].[Item SKU] = ""
Forms![Returns Entry Form]![Item SKU].SetFocus <-----
GoTo SkipSKU
End If
.FindFirst "[SKU] = " & Forms![Returns Entry Form].[Item SKU] & ""
If .NoMatch Then
ItemNumber = ""
ItemDescription = ""
Else
ItemNumber = .Fields("Item Number")
ItemDescription = .Fields("Item Description")
'UPC = .Fields("UPC")
End If
SkipSKU:
End With
rs.Close
db.Close
Forms![Returns Entry Form].[Vendor Item Number] = ItemNumber
Forms![Returns Entry Form].[Vendor Item Description] = ItemDescription
End Sub
This SetFocus line stubbornly refuses to work. The rest of the code works
fine, i.e. if an alphanumeric string is entered, the message box appears and
the control is cleared, but the focus moves to the next control no matter
what I try. I really need the focus to move back to the Item SKU textbox.
Anybody have any ideas as to why this SetFocus line seems to be getting
ignored?
Private Sub Item_SKU_AfterUpdate()
....
....
Set db = CurrentDb
sql = "SELECT * FROM [Vendor Item Info]"
Set rs = db.OpenRecordset(sql)
With rs
.MoveLast
.MoveFirst
If IsNumeric(Forms![Returns Entry Form].[Item SKU]) = False Then
MsgBox "The SKU field must be numeric. Please re-enter the SKU."
Forms![Returns Entry Form].[Item SKU] = ""
Forms![Returns Entry Form]![Item SKU].SetFocus <-----
GoTo SkipSKU
End If
.FindFirst "[SKU] = " & Forms![Returns Entry Form].[Item SKU] & ""
If .NoMatch Then
ItemNumber = ""
ItemDescription = ""
Else
ItemNumber = .Fields("Item Number")
ItemDescription = .Fields("Item Description")
'UPC = .Fields("UPC")
End If
SkipSKU:
End With
rs.Close
db.Close
Forms![Returns Entry Form].[Vendor Item Number] = ItemNumber
Forms![Returns Entry Form].[Vendor Item Description] = ItemDescription
End Sub
This SetFocus line stubbornly refuses to work. The rest of the code works
fine, i.e. if an alphanumeric string is entered, the message box appears and
the control is cleared, but the focus moves to the next control no matter
what I try. I really need the focus to move back to the Item SKU textbox.
Anybody have any ideas as to why this SetFocus line seems to be getting
ignored?