Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Control in number of characters entered in a field

Status
Not open for further replies.

pdtit

Technical User
Nov 4, 2001
206
BE
Hello,

I have the following feature in my mind to have a minimum of errors on entering data in a form :

The form is used to enter products with their EAN-code. As the EAN-code is the most important field to determine the correct product, the code has to be correct.

What I want to check after entering a EAN-code in the field :

1. number of characters should be 13
2. if number of characters < 13, fill up with &quot;0&quot; from the left

eg. if a code is entered 1234567890, the system would inform the user that the code is not correct, and change it to 0001234567890 (in this way, the barcode-scanner can read the EAN-code correct, as it doesn't look at the leading zero's)

Can anyone give me some VBA-lines to have this done ??

Regards,

PdtIt
 
If the value entered will always be numeric, its easier than you think. Enter thirteen zeros in the Format property of the field.

You could also enter thirteen zeros in the Input Mask property of the field - this will force the user to enter thirteen numeric characters but its a bit sadistic if the number entered will be often less than thirteen characters long.

Rod

 
Rod,

I tested both of your suggestions :
- the first one didn't worked. the result stays the same.
- the second one (input mask) works to do the control on the number of characters; however, it doesn't add the zero's to the left if the number of characters isn't equal to 13.

Any other idea's ??

Regards,

PdtIt
 
pdtit,
I think you will find that if you try reading EAN code on a scanner without assigned digits you won't get a result.
The code is designed to have 12 digits and a check digit. The check digit is computed from the other 12. If you try to put leading 0's in the EAN number the scanner will not recognize it.
Jim
 
Jim,

Thx for the reply. However, it seems to work with the leading 0's.

The scanner scans different formats, not just EAN's. That's maybe a reason why it can recognize this.
I found out that when I printed the barcode-field with only 12 numbers, it added a 13th to my string automatically, of course not being the correct one.
When entering my barcode with a leading 0, it is printed as such on the label, and the product is scanned correctly, as the barcode-field in my database has the leading 0 as well.

Greetz,

PdtIt
 
pdtit,
Sounds like your scanner is reading code 39, if it's giving you the numbers. I completed a db on UPC-A a couple of months ago and am pleased with the results.
DougP, a regular contributor to this fourm is a UPC genius. He might have the solution. I'm not a programmer and, as i have stated in other fourms, &quot;Just Muddle through.&quot;
Jim
 
Jim,

The discussion of it is correct according to UPC-standards is not relevant to my question for the moment. I know my scanner can handle many different kinds of barcodes, of which I'm not the specialist either.

The same question still goes on, even if it was a general text-field or numeric field :
a) how to check the number of characters entered
b) fill the field with leading zero's if not equal to 13 characters.

Thx if anyone could help me with this one.

PdtIt
 
private sub txtField_AfterUpdate

if len(txtField.value) < 13 then
txtField.value = String(&quot;0&quot;,13 - len(txtField.value)) & txtField.value
MsgBox &quot;appropriate message&quot;
end if

end sub
(assuming that the name of the field is &quot;txtField&quot;)
(of course, before this check you can also make a check on the field that it has a numeric value and is not null)

Good luck
 
Sorry,
There's one mistake in this code.
in String() function first comes the number of characters and then the character. Like this:
txtField.value = String(13 - len(txtField.value),&quot;0&quot;) & txtField.value


 
Galar,

MANY MANY MANY thx

I suffered already 3 hours on this issue, especially with the barcoding-stuff mentioned above.

As it is working now, I'm very happy and can break my head on another issue/feature.

Regards,

PdtIt



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top