Solved

Scan two Barcodes and then compare the values (without pressing any keys)

Posted on 2007-03-19
11
1,142 Views
Last Modified: 2008-01-09
I have two unbound textboxes on a unbound form.

What I want to do is Scan the first Barcode into txtMedBag, then have the focus change to the second textbox (txtSubBracelet). Scan the second barcode into txtSubBracelet and then compare the two Barcode entries.

The following code is in the On Change Event of the Second Textbox (txtSubBracelet):

    If Nz(txtMedBag, "") <> txtSubBracelet Then
        MsgBox "The Scan Numbers do not Match. " & txtMedBag & ":" & txtSubBracelet
        DoCmd.Beep
        DoCmd.GoToControl "txtSubBracelet"
        txtSubBracelet = ""
        'Cancel = True
        Exit Sub
    Else
        'MsgBox "The Scan Numbers Match. " & txtMedBag & ":" & txtSubBracelet
        DoCmd.GoToControl "txtMedBag"
    End If

When I scan the barcode, I haven't been able to get the focus to change to txtSubBracelet from txtMedBag, and the code fires and only grabs the first character from the bar code scanner (Symbol Brand - USB). I've read numerous threads here on EE, yet none have pointed me in the right (specific) direction.

What I have works (perhaps not as efficiently as possible) when the User presses the Enter or Tab keys.

Thanks for your Help, Imoutwest.
0
Comment
Question by:Imoutwest
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
11 Comments
 
LVL 57
ID: 18751793
<<When I scan the barcode, I haven't been able to get the focus to change to txtSubBracelet from txtMedBag, and the code fires and only grabs the first character from the bar code scanner (Symbol Brand - USB). I've read numerous threads here on EE, yet none have pointed me in the right (specific) direction.>>

 Wrong event.  Onchange fires for every change in the control.  You want AfterUpdate.

JimD
0
 
LVL 7

Author Comment

by:Imoutwest
ID: 18751862
Agreed (or so I've realized) however, in the AfterUpdate, how do I fire the event once I scan the barcode(s)?
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 18751941
With scanning, you have two choices:

1. Use the OnChange event to monitor the control.  When you see a specific length or a specific character from the gun (program the gun to suffix something that would not be scanned), do a SendKeys with vbTab or setfocus to the next control.

2. Have the gun programmed to suffix a carriage return to the scanned data.

  In both cases, the BeforeUpdate and AfterUpdate events will fire.  

  Note that if you have the gun suffix a character, you can prevent someone from manually entering a number by using the BeforeUpdate event to check for the special character and cancel if you don't find it.

  Not always a wise idea though as many barcodes may not be scanable.

JimD.
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 44

Expert Comment

by:GRayL
ID: 18751991
Some guys think once you have a gun you can do anything;-)
0
 
LVL 7

Author Comment

by:Imoutwest
ID: 18751994
Thank you,

I will check this out, and get back to this in a few hours... Imoutwest
0
 
LVL 57
ID: 18752010
<<and get back to this in a few hours... Imoutwest>>

  well Imouteast, so you may not get a response till tomorrow.  It's getting late in the day here.

JimD
0
 
LVL 7

Author Comment

by:Imoutwest
ID: 18752029
Well, I haven't been able to figure this out yet, and I thought it would be simple...
0
 
LVL 7

Author Comment

by:Imoutwest
ID: 18752035
Take care, we'll work this out tomorrow (AM - I hope).
0
 
LVL 7

Author Comment

by:Imoutwest
ID: 18756889
GRayL,

I did the unthinkable and read the users' manual for the scanner...

Jim

Once I read the manual I resolved the issue by programming the Scanner to include a LineFeed after each scan. It was what I wanted, but didn't know how to setup the scanner (went to the manufacturer's web site).

Problem solved, wish it was always this simple... Thanks for your help (push in the right direction) Imoutwest
0
 
LVL 57
ID: 18756952
Glad to hear that your on your way....

JimD
0
 
LVL 44

Expert Comment

by:GRayL
ID: 18757037
In the Air Force when we were stumped, the boss would always seem to be to resolve it by  saying: "RTFI!" - three of the words are 'Read The Instructions' ;-)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question