By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,931 Members | 1,247 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,931 IT Pros & Developers. It's quick & easy.

Limit a strings length when doing data entry

P: 7
I was wonder how i would go about limiting a length of a string that is going to be entered into a text box. An example my explain this better:
the data is coming from a barcode that reads: ABCDEF 1a2b3c
as you can see there are two sections one letter sections and one alphanumeric section. the first is only 6 characters long and then a space and then a set of 6 alphanumeric charaters. If this is being entered into a text box/combo box is there a way to only use the first 6 characters, ABCDEF, from the string??
Thanks for the advice

developing in ms access 2000
Jul 25 '07 #1
Share this Question
Share on Google+
9 Replies


Rabbit
Expert Mod 10K+
P: 12,366
You'll want to look at input masks from the help file, gives you all the info you need.
Jul 25 '07 #2

P: 7
Well i have the input mask working correctly, except that space between the two data sections must be a carraige return.This causes a problem when i go to my lostFocus event property of the text box i use a dcount to see if that value is in the list. Since there is a carraige return once the data is entered it will also try to insert the record when not all data fields are full so how can i just ignore any characters after the first 6?
Jul 26 '07 #3

Rabbit
Expert Mod 10K+
P: 12,366
I'm not following. Could you explain again and provide an example?
Jul 26 '07 #4

P: 7
I'm not following. Could you explain again and provide an example?
So what happens is the user selects the first text box and will scan a barcode that contains the following: ABCDEF 1a2b3c. What happens is the the text box will then have the data ABCDEF, which is the information that i need since it is a userID. But then the ' ' (blank space) in the middle of the bar code data is a carriage return so once it is read it will either go to the next field or execute the command button. So if the focus of the form goes to the next field then the 1a2b3c is displayed, which i dont want; and if there is a command button on the form then it will be executed. So the problem is that i dont want anything after the sixth character to be read.


Let me know if you need more explaining.
Jul 26 '07 #5

Rabbit
Expert Mod 10K+
P: 12,366
I've never used a bar code scanner with Access before so I don't know how it works.

However, I assume the bar code scanner comes with software? Rather than a carriage return could you get the scanner to return something else?

In Access you can also change the behavior of the Enter key. I forget exactly where it is right now.

Also, are you able to intercept and manipulate the information from the barcode scanner before it enters the form? If so you can use just the first 6 characters.

If you could tell me more about how the barcode scanner works with Access I could probably come up with more ideas.
Jul 26 '07 #6

P: 7
Well the scanner's input is just in the form of another listener, it works the same as a keyboard basically. The only difference between the two is that with a keyboard you type each character in whereas with the scanner is it a full string. Now as far as for the software for the scanner, there really is none all you need to do is download a barcode font for something like ms word and you can make any barcode you want. The only rule you have to follow is the barcode must start with a *, and end with a * (by * i mean its barcode equivalent). And you can do this because the scanner will take the barcode and convert it into ASCII characters and display it to the screen or where ever. But for the project i am working on i cant really change the format of the existing bar codes, so i am stuck with the 'ABCDEF 1a2b3c" format.

So what i tried to do is make a blank text box (tab index 1) that has the index right after my user name text box (tab index 0) so when the carriage return is recogized the second part of the barcode, 1z2b3c would go to the second text box which i got to work. Then i tried to make the second text box not visible so you wouldnt see the 1a2b3c data from the bar code and the data would just be ignored. but the problem i had with that was once i set the second text box to not visible the 1a2b3c data would just be entered into my tab index 3 field, which i dont want.

let me know if that doesnt make sense or you need more explaination
Jul 26 '07 #7

Rabbit
Expert Mod 10K+
P: 12,366
If that's the case then I think you'll need to either leave that textbox visible and put it somewhere where it can't be seen or change the behavior of the carriage return. I'm pretty sure it's one of the options.You can tell it not to move on to the next tab stop.

EDIT: It's in Tools>Options under the Keyboard tab. In the Enter key behavior. Hopefully turning it off will work for the barcode scanner. Otherwise I think your only option is to make the extra textbox really small and hide it behind another control.
Jul 26 '07 #8

P: 7
Well thanks for the input, ill try out that stop tab option and if that doesnt work ill just have to hide it. Thanks for the help, I really appreciate it. I just started working with access like 1.5 months ago for an intership so i dont know all the ins and outs yet but i learn new stuff every day. Thanks again.
Jul 26 '07 #9

Rabbit
Expert Mod 10K+
P: 12,366
Well thanks for the input, ill try out that stop tab option and if that doesnt work ill just have to hide it. Thanks for the help, I really appreciate it. I just started working with access like 1.5 months ago for an intership so i dont know all the ins and outs yet but i learn new stuff every day. Thanks again.
Not a problem, good luck. Maybe one of the other experts will know of a better way to do it.
Jul 27 '07 #10

Post your reply

Sign in to post your reply or Sign up for a free account.