How to filter a record using barcodes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rob Amor
    New Member
    • Sep 2010
    • 30

    How to filter a record using barcodes

    I have a form called “Front” with an unbound textbox called "BarcodeCapture "

    I have another form called "Gen_Users" which holds all my client information with a bound textbox called “BarCode”

    “BarCode” contains a random number generated using Rnd()

    I want to be able to enter a number into “BarcodeCapture ” (ie scan a barcode) and automatically go to the corresponding record in Gen_Users.

    I have tried to use the applyfilter function but I am getting nowhere. Any help would be greatly appreciated as I have spent ages going round in circles.

    Thanks
  • TheSmileyCoder
    Recognized Expert Moderator Top Contributor
    • Dec 2009
    • 2322

    #2
    Do you have a function to capture the barcode? If not I can try to find a thread from a while back discussing such an issue.

    Once you have it, you can use code like:
    Code:
    Me.RecordSet.Findfirst "Barcode=" & me.BarCode
    to go to your item.

    Comment

    • Rob Amor
      New Member
      • Sep 2010
      • 30

      #3
      Thanks for your reply. No I don't have a function to capture the barcode. If you have one it would be fantastic.

      Comment

      • liimra
        New Member
        • Aug 2010
        • 119

        #4
        //

        What TheSmileyOne stated will work when you have TheCapture field on the same form. You have the two fields on different forms, so I think you must use the OpenForm function to open the record that matches the criteria (barcode).

        Add the following code to the AfterUpdate Event of the "BarcodeCapture " field on the "Front" Form.

        Code:
        DoCmd.OpenForm "Gen_Users", acNormal, , "Barcode = " & Forms!Front!BarcodeCapture
        Now once you update the "BarcodeCapture " field, the other form will open where the barcode is equal to the barcodecapture.

        Of course, you can add the code to the OnClick event of a button on the "Front" Form or to any other event.

        Regards,
        Ali

        Comment

        • Rob Amor
          New Member
          • Sep 2010
          • 30

          #5
          Thanks for the code. It works fine on a button click but not in the unbound textbox which is very confusing? I have tried it onclick, onchange and on update and it filters but always gives the first record? Like I say it works fine in the onclick of the button, maybe it's an unbound issue?

          Comment

          • liimra
            New Member
            • Aug 2010
            • 119

            #6
            //

            I would recommend that you filter on button click; you however can filter with any other event. For instance, you can filter on the LostFocus event of the unbound text field, or on its AfterUpdate event. One problem with the OnClick event is that it will open the form even when the field is empty (of course you can overcome this by using If...Then); Another thing is that you have to click it again when entering the barcode and this what is causing the confusion. All in all, you can use AfterUpdate or LostFocus but again I advise to use separate button.

            Anyways, try these events and let me know if you still have an issue.

            Regards,
            Ali

            Comment

            • TheSmileyCoder
              Recognized Expert Moderator Top Contributor
              • Dec 2009
              • 2322

              #7
              This is the post I was thinking about.
              how--to-get-scanned-data-into-my-forms

              Comment

              • Rob Amor
                New Member
                • Sep 2010
                • 30

                #8
                Thank you so much for your help guys. I think I have it working from a button and assuming my tests go well I am very pleased with what i have.

                Thanks again

                Comment

                • liimra
                  New Member
                  • Aug 2010
                  • 119

                  #9
                  Happy to know that. Please mark this post as answered so it becomes more helpful for others.

                  Regards,
                  Ali

                  Comment

                  Working...