?
Solved

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

Posted on 2007-03-19
11
Medium Priority
?
1,178 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 58
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 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 2000 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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
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 58
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 58
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Suggested Courses

762 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