Link to home
Start Free TrialLog in
Avatar of iainmacleod
iainmacleodFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Symbol Barcode Scanner into MS Access 2010

I am developing a scanning database in MS Access 2010 and using Symbol/Motorola LS 4278 Bluetooth Barcode scanners.
Some of the barcodes I scan work perfectly but some only repeat the data from the previous line in the table. Almost as though there is something in these barcodes that copies the line above... It sounds crazy and is a little difficult to explain.

When scanning you can see the correct data going across the field, it then disappears and is replaced by the data in the field above.

I have created a brand new table in a blank database and it still occurs. In Excel or Foxpro database it works perfectly.

I have attached an example of the problematic code. Not sure if its res will be good enough though.

Any ideas would be gratefully received.
Barcode.JPG
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

<<It sounds crazy and is a little difficult to explain.>>

 No, I understood.  Couple of comments:

1. Keep in mind that scanned data will look as if it came from the keyboard.  That means any keyboard shortcuts you have defined (or Access uses) will be invoked if the data contains that sequence.

2. Watch out for any navigation keystrokes that might be being sent.  For example, a tab character (x09).

To pin this down,  I would in a new database create a single test form with a single control and a command button.  

Create a procedure for the OnClick for the button with nothing more then a STOP in it.   Then open the form and scan the bar code.  Then click the button.

Now you can check the contents of the text control using the debug Window and see what it actually contains.

Jim.
Avatar of iainmacleod

ASKER

Hi Jim,
Thanks for this.
Have created a form with a text control and can scan the code. In the button i have an event procedure with STOP. I dont understand how to use the debug window though.
Iain
With the text control having the focus, scan the bar code.

Since the form is unbound, it's not going to go to another record.

Now click the button.  The VBA window will come up.   Key:

Ctrl/G

 to bring up the debug window.

Now you can do things like:

?  Me.<mycontrolname>

"?" being short for:

Debug.Print

 and see the value of the text control in the debug window.   You can use things like Asc(), left(), mid(), etc to pick it apart and see what characters your actually getting.

 That should give you a clue as to what's going on.  For example, you see an 09, which is a tab character.

 In Access by default, a tab character will move you to the next field.   If your on the last field in a form, then you might move to the next record.

 It's also possible you had some code interferring with the scanning, which is why I suggested a clean DB.

 You next step in debugging if you find nothing here would be to create a table in this DB, then bind this test form to it and try scanning a bunch of values.

 If the table looks OK after that and your not moving from record to record, then the problem is something your doing in your original DB with macro's or code.

 You can also place STOPs in things like the AfterUpdate event of the form, or OnCurrent once it's bound to a table to see what events are getting executed.  You can also add a second text control to see how it's cycling through controls/records.

 At the moment though, you've reduced it down to the simplest test possible.  You want to build up from here.  At some point, you'll find out what's going on.

Jim.
One other thing to check:

Look at the driver settings/scanner settings and see if it is set to transmit any prefixes or suffixes on the scanned data.  Depending on what it is, that can cause problems.

Jim.
Ok great. I have done that:
When scanning barcode onto Unbound control i get the correct barcode with no unexpected characters. (Data is the same as when i scan to Excel)
If i bind the form to a table and make it continous, the first Barcode I scan is correct, the second one I scan (Although is different data) it shows as exactly the same as the first barcode.

This is a completely clean database..
<<If i bind the form to a table and make it continous, the first Barcode I scan is correct, the second one I scan (Although is different data) it shows as exactly the same as the first barcode.>>

 Did you bind the control as well?   Unbound controls in a continous form view will show the same value on every row.

Jim.
Yes i bound the control
<<(Data is the same as when i scan to Excel)>>

 Your saying two cells are the same in Excel when you scan two different codes?  Then that says the problem is in the gun and/or driver.

But that doesn't add up with your comment in your original post that this works in Foxpro or Excel fine.

I'm confused.

Take your test setup, unbind the form and control.  Add a second text control to the form.

Set focus to the first, scan one bar code, then sent focus to the second (manually) and scan the second bar code.

Do you get the same data or no?

Jim.
Sorry to confuse you. .
In excel and on an unbound form with 2 controls I can scan 2 different barcodes and get 2 different sets of data.as I would expect.

Only when I bind the control on a continuous form or scan directly to a table do I get the first barcode data duplicating...
OK.  So what happens on the test form with two seperate text controls with the forms and controls unbound?

Jim.
Data displays correctly
Take it one step further then; bind the form to a table and the control to a field, but leave it in regular form view.
 
 Scan the code for the first record, then move to the second record and scan the second bar code.   Data should be different.

If so, then:

a. you sure your binding the control to a field when in continous form view?

b. You are the one manually moving between the two records when in continous from view, correct?

c.  If you look at the table directly, you see the same data in both records?

Jim.
Thanks Jim.  I will check that out tomorrow.  Appreciate your time
In regular form view with the control bound i scan 2 different barcodes but get the same data in each.....
It is almost as though once the table updates it copies the previous record.
Ctrl/' will copy the previous value.

What is the bar code data for each of the scans?

Jim.
If I scan to Excel then this is the data:
LEPPL13111234567
LEPPL13120000121

Scanning straight to Table i get duplicates of whatever the first one I scan..
I have just used Techoriver Free barcode generator, copied that data and created new barcodes and all works perfectly. It must be something in the format of the original codes..
Found out that barcode is CODE128, do you think that might be the issue?
Quite possibly.  Code 128 can do the full ASCII range, so it can send a control code.

Let's see if that's really what's going on:

1. Set the Keypreview property of your form to Yes.

2. Then in the Keydown event, do:

  If KeyCode > 17 Then KeyCode = 0

  This disables the Ctrl Key.

 Now see if it works right.

Jim.
HI,
with the If statement in the keydown event nothing scans at all?
Sorry, check should be:

 If Shift = 2 then keycode = 0

That will disable the control key.

Jim.
That was it.... Scanning perfectly now with correct data..
Well sorry to say, but I don't think were quite out of the woods yet.  So now we know what's happening, but not why.

I'm not sure I understand why the Code 128 results in a Ctrl character being inserted.  I'm wondering if the gun/driver is somehow doing that.

What is the actual data you have encoded?

Jim.
The barcodes are not created by me so not sure exactly how they are done.
Dont think it is the Gun as other 128 codes scan OK.
With the ability to remove the Ctrl i can at least get me application to do what is needed.
ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Jim, really appreciate all of your help
No problem.  I'm just sorry it was such a drawn out process (been REALLY busy as of late - in fact I'm going nuts at the moment - It's been a crazy couple of weeks).

Jim.