Results 1 to 8 of 8
  1. #1
    PatLeeBauer is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2020
    Posts
    3

    Passing Scanned Barcode to Query as Selection Criteria


    Scanning barcode into control field on form then running query (form stays open) using that field as selection criteria in a query to open just those records. I'm getting no results. When I type in the anything for the barcode when setting the item up, then type those same numbers in the form to query, it works fine. Made sure codes 39 & 128 are turned on for the scanner. What am I missing? First time using barcodes so my knowledge pool is pretty shallow.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Are those codes either a Tab or Enter? The data has to be committed before a query will see the contents of the textbox.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Maybe the form is still "dirty" after the scan, try to add Me.Dirty=False before running the query.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  4. #4
    PatLeeBauer is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2020
    Posts
    3
    They're set up as tabs. The choices the scanner offers (Qr codes I scan) are; tab; LF+CR; CR; NONE;CR+CR;Trigger Mode;Continue Scan Mode; Auto Sense Mode. There is also a Factory Default to set back to. I selected Tab as there was no option for Enter. Now when I scan the barcode, it does automatically move the cursor to the next field. Unfortunately, it didn"t fix my issue. I'm still getting no results.

    The barcode field in my items table is set as long text. The control on my form called barcodepass (which is what is passed to the query criteria) did not have long text option, so its set to whatever the default is. By action, it appears that although the string of characters scanned in both the barcode and barcodepass fields are identical, they're not matching up. I've checked and neither field has any spaces after the string. I'm just at a loss. Any other thought?

  5. #5
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    How you initiate the query?
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  6. #6
    PatLeeBauer is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2020
    Posts
    3
    I used the After Update, and opened the window where you see code (I'm not a programmer), I added your statement so it looks like this:

    Option Compare Database


    Private Sub BarcodePass_AfterUpdate()


    Me.Dirty = False


    End Sub


    Private Sub Form_Load()


    End Sub

    When I run it, I'm still getting no matches. Did I do this wrong?

  7. #7
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    You mention a query, do you run that manually? I would have expected something like this:
    Code:
    Private Sub BarcodePass_AfterUpdate()
    Me.Dirty = False
    Msgbox "Form saved!"
    Docmd.OpenQuery "qryYourQueryName"
    End Sub
    I added the msgbox so you could tell if the code ran.
    Can you post the two sets of characters you are trying (scanned vs manually typed)? If you compare the two in a query what do you get (Forms!frmYourForm!Barcode=Forms!frmYourForm!Barco dePass)?

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    You might also scan into an instance of Notepad and see if there's anything odd there. I'm wondering if there's a tab character in there instead of it tabbing out of the textbox (or in addition to).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Passing Query Criteria to subform queries?
    By tmartin in forum Queries
    Replies: 2
    Last Post: 05-22-2015, 06:44 PM
  2. Replies: 2
    Last Post: 02-05-2015, 11:32 AM
  3. Replies: 9
    Last Post: 05-30-2012, 12:57 AM
  4. Passing form fields criteria to a Query
    By yosik20 in forum Queries
    Replies: 1
    Last Post: 05-12-2011, 04:24 AM
  5. Replies: 3
    Last Post: 08-08-2010, 01:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums