Solved

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

Posted on 2007-03-19
11
1,121 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
count unique records in access report 2 23
Format vertical text in Access 2016 3 33
Error in query expression 3 37
access 7 26
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

867 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

16 Experts available now in Live!

Get 1:1 Help Now