none
Barcode Scanner in Access RRS feed

  • Question

  • Hello, I am trying to use a barcode scanner to input data into two fields in an entry.  I am using a form that has three text boxes: Barcode, Scanner, and Time.  Barcode and Scanner are the two fields that I would like to scan barcodes into (the scanner functionally working as a keyboard), but I would like the form to automatically change the focus to Scanner from Barcode once something is scanned into the Barcode field.  I would then want the form to save the entry and clear the boxes, then se the focus in the new entry back to barcode.  So far all of my attempts at using the "setFocus" feature have not worked; every time I try to scan something into the Barcode field the focus jumps down to the "Time" box, which I would only like to use as a time stamp. 

    Looking forward to your responses!

    Here's what I have:

    Private Sub Barcode_AfterUpdate()
    If Left(Me.Barcode, 5) = "00000" Then
    Scanner.SetFocus
    End If
    End Sub

    Private Sub Scanner_AfterUpdate()
    If Left(Me.Scanner, 7) = "STATION" Then
    DoCmd.GoToRecord , , acNewRec
    Barcode.SetFocus

    End If

    End Sub

    Wednesday, July 29, 2015 6:59 PM

All replies

  • Hi Kel,

    Some scanners can set a Carrage Return at the  end of the scan to On or OFF.

    If you turn this off then the scan will not send the CR and not move to the next row.

    Alternatively you could try the Before Update or Change events to strip out the CR/LF...


    Brian, ProcessIT- Hawke`s Bay, New Zealand

    Wednesday, July 29, 2015 11:29 PM
  • Hello,

    I don't think I'm able to program the scanner to do anything differently...  And if I could I don't think I know how.

    What would the before update or change events look like?

    Thursday, July 30, 2015 12:32 AM
  • Check the scanner, some have a CR/LF switch.

    in the Property Sheet of your BarCode TextBox select the Events Tab.

    Here you can see the event that Access can capture. Click the ... at the right of the before update

    You may be able to identify the CR/LF character and strip it out.

    You could also try using the On Enter event of the Time textBox to move back to the "Scanner"


    Brian, ProcessIT- Hawke`s Bay, New Zealand

    Thursday, July 30, 2015 12:40 AM
  • The scanner doesn't have one of these switches. 

    I added some things and here is what I have:


    Private Sub Barcode_AfterUpdate()
    If Len(Me.Barcode.Text) = 7 Then
    Scanner.SetFocus
    Else: Me.Barcode.SetFocus
    End If

    End Sub

     

    Private Sub Scanner_AfterUpdate()
    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.RunCommand acCmdRecordsGoToNew

    Me.Barcode.SetFocus
    End Sub

    This currently allows me to scan both barcodes and saves the record, as well as creating a new blank record.   But even with the Me.Barcode.SetFocus in the second part, the focus stays on the Scanner control instead of moving back up to the Barcode control.  My tab order is correct, so I don't know how to fix this. 

    Thursday, July 30, 2015 4:07 PM
  • Hi Kel,

    Good Progress!

    Try the docmd version of this: 

    docmd.GoToControl ("Barcode")


    Brian, ProcessIT- Hawke`s Bay, New Zealand

    Thursday, July 30, 2015 9:23 PM