Prevent user keying by keyboard and can only input by barcode scanner

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alvintiow
    New Member
    • Jul 2008
    • 1

    Prevent user keying by keyboard and can only input by barcode scanner

    Hi,

    I intend to use barcode for input and prevent user to modify the barcode they scan, user are not allow to input the barcode number by keyboard.



    Please advise how to do this.

    Thanks.

    Regards,
    Alvin
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    Hi. Most barcode scanners for PCs use the keyboard connection, and the scan behaves just as if you had typed the value. I can see no way to prevent users either keying the barcode directly, or altering it once a barcode has been scanned.

    Even if you could implement such a facility, you would also be stopping users from manually keying barcodes if the scan fails for some reason.

    -Stewart

    Comment

    • missinglinq
      Recognized Expert Specialist
      • Nov 2006
      • 3533

      #3
      Stewart raises a valid point, but if you absolutely must do this , this code will do the job:
      Code:
      Private Sub txtBarCode_KeyDown(KeyCode As Integer, Shift As Integer)
        KeyCode = 0
      End Sub
      Or you could simply set the textbox's Locked Property to Yes. I don't have a scanner, so I can't really test this, but both methods appear to handle your situation.

      Welcome to Bytes!

      Linq ;0)>

      Comment

      • Delerna
        Recognized Expert Top Contributor
        • Jan 2008
        • 1134

        #4
        I have done both of those for the purpose of obtaining part labels.
        Stop the user entering maually similar to missinglig's code.
        Stopped production getting labels because the scanner failed.

        We finished up enabling users to manually enter part numbers, but we deliberately made it more difficult to obtain them that way than by using the scanner. It worked :)

        Edit
        Actually, on second thoughts, I think I may have had to wrap the barcoded number up in special characters and check the entered number for the presence of those characters before allowing the entry.

        Comment

        • IAMREALITY
          New Member
          • Sep 2016
          • 1

          #5
          This is how I solved it:

          Code:
          Public FirstInput As Date
          
          Private Sub Text0_GotFocus()
          FirstInput = Empty
          End Sub
          
          
          Private Sub Text0_KeyUp(KeyCode As Integer, Shift As Integer)
          Dim TimeDiff As Integer
          'Procedure uses first keystroke to start timing, and every subsequent keystroke compares
          'to the first, and if more than 1 second has elapsed, warns user to use the scanner and resets field.
          'tabbing away or back to the field resets the timer. Tabbing off the field or hitting enter to move to
          'the next field will not be counted as keystrokes.
          
          If KeyCode <> 9 And KeyCode <> 13 Then
          If FirstInput = Empty Then
          FirstInput = Now()
          Else
          TimeDiff = DateDiff("s", FirstInput, Now())
          End If
          
          If TimeDiff > 1 Then
          MsgBox ("Please scan in using the attached scanner")
          Text0.Text = Empty
          FirstInput = Empty
          End If
          
          End If
          
          End Sub
          
          Private Sub Text0_LostFocus()
          FirstInput = Empty
          End Sub

          Comment

          • ADezii
            Recognized Expert Expert
            • Apr 2006
            • 8834

            #6
            You can actually disable all User Input via the Mouse and Keyboard then re-enable it via the API, but this may be somewhat extreme.

            Comment

            Working...