Solved

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

Posted on 2007-03-19
11
1,161 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 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Familiarize people with the process of utilizing SQL Server views 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 Access…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

726 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