Solved

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

Posted on 2007-03-19
11
1,104 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
  • 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
 
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now