I was working on some code with some help from you guys. I have the code running now but when I search for an item if its not there I want to display a message box announcing it. When I run the code normally it skips the msgbox code(or displays it someplace not visible to the user). IF I put a stop command in, the code will execute perfectly and display the msgbox as requested. If I run it normally it skips it again.
I am totally baffled by this one.
I am totally baffled by this one.
VBA Code:
Private Sub barcode_Change()
Dim Found As Range
Dim Search As String
Dim ws As Worksheet
Dim SearchColumn As Variant
Search = Me.Barcode.Value
If Len(Search) <> 13 Then Exit Sub
Set ws = ThisWorkbook.Worksheets("Physical Inventory List")
SearchColumn = 5
Set Found = ws.Columns(SearchColumn).Find(Search, LookIn:=xlValues, lookat:=xlWhole)
If Not Found Is Nothing Then
With Found
.Offset(, 2).Value = Found.Offset(, 2) + Me.qty.Value
Confirmation.Caption = Found.Offset(, -3) & " has been recorded in inventory"
inv_count.Caption = "Counted " & Found.Offset(, 2) & " Inventory " & Found.Offset(, 1)
End With
Else
'this is the msgbox that I want to display if the barcode is not found in the search.
res = MsgBox("Barcode " & Search & " Not Found. " & Chr(10) & "Try again", 48, "Not Found")
End If
Me.Barcode.Value = ""
Me.Barcode.SetFocus
End Sub