Barcode scanner issues. Scan to verify order

catigo

New Member
Joined
May 18, 2013
Messages
5
Hello,

I have created a userform to scan a specific barcode and verify against list on another sheet. As of now, everything works perfectly, but I am having issues with the actual scanner. When I scan the barcode, only the last digit of the number is populated into the txt box. I would like the entire barcode number to be populated in my textbox, but I am unsure of where I am going wrong. Any help would be much appreciated.

Code:
Private Declare Function sndPlaySound32 _
    Lib "winmm.dll" _
    Alias "sndPlaySoundA" ( _
        ByVal lpszSoundName As String, _
        ByVal uFlags As Long) As Long
Private Sub ThisBID_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then
    Dim BID As String
    
    
    LastRow = Sheets("Stand Counts").Cells(Rows.Count, 1).End(xlUp).Row
    BID = ThisBID
    If LastBID = "" Then
        LastBID = ThisBID
        With Sheets("Stand Counts").Range("A1").Resize(LastRow, 1)
            Set FoundBID = .Find(BID, LookIn:=xlValues)
            If FoundBID Is Nothing Then
                NotFoundError
                Exit Sub
            End If
            With FoundBID
                .Interior.Color = RGB(0, 255, 0)
            End With
        End With
    Else
    With Sheets("Stand Counts").Range("A1").Resize(LastRow, 1)
            Set LastBIDRow = .Find(LastBID, LookIn:=xlValues)
            Set FoundBID = .Find(BID, LookIn:=xlValues)
            If FoundBID Is Nothing Then
                NotFoundError
                Exit Sub
            End If
            If LastBIDRow.Offset(1, 0) = FoundBID Then
                With FoundBID
                    '.Select
                    .Interior.Color = RGB(0, 255, 0)
                End With
                
            Else
                sndPlaySound32 scanSound, 0&
                Application.Wait Now + TimeValue("00:00:01")
                MsgBox "Not In Order"
                MsgBox "Order will be started from next Scan."
                LastBID = ""
            End If
    End With
    End If
    ThisBID = vbNullString
    cmd_Clear.SetFocus
    ThisBID.SetFocus
    ThisBID.SelStart = 0
    
End If
ThisBID.Text = ""
End Sub
Private Sub NotFoundError()
    sndPlaySound32 scanSound, 0&
    Application.Wait Now + TimeValue("00:00:01")
    MsgBox "Data not found." _
        & vbCr & "Please check to make sure Plot Tag is correct."
    MsgBox "Order will be started from next Scan"
    LastBID = ""
    ThisBID = vbNullString
    cmd_Clear.SetFocus
    ThisBID.SetFocus
    ThisBID.SelStart = 0
End Sub
Private Sub cmd1_Click()
TxtNumber.Value = TxtNumber.Value & "1"
End Sub
Private Sub cmd2_Click()
ThisBID.Value = ThisBID.Value & "2"
End Sub
Private Sub cmd3_Click()
ThisBID.Value = ThisBID.Value & "3"
End Sub
Private Sub cmd4_Click()
ThisBID.Value = ThisBID.Value & "4"
End Sub
Private Sub cmd5_Click()
ThisBID.Value = ThisBID.Value & "5"
End Sub
Private Sub cmd6_Click()
ThisBID.Value = ThisBID.Value & "6"
End Sub
Private Sub cmd7_Click()
ThisBID.Value = ThisBID.Value & "7"
End Sub
Private Sub cmd8_Click()
ThisBID.Value = ThisBID.Value & "8"
End Sub
Private Sub cmd9_Click()
ThisBID.Value = ThisBID.Value & "9"
End Sub
Private Sub cmd0_Click()
ThisBID.Value = ThisBID.Value & "0"
End Sub
Private Sub cmd_Enter_Click()
Dim LastRow As Long
LastRow = Sheets("Stand Counts").Cells(Rows.Count, "G").End(xlUp).Row
Sheets("Stand Counts").Cells(LastRow + 1, "G").Value = ThisBID.Text
With Selection
        .Interior.Color = RGB(99, 115, 115)
        
    End With
Me.Hide
ThisBID.Text = ""
End Sub
Private Sub cmd_Clear_Click()
ThisBID.Text = ""
End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top