Quick way to remove a letter from string on entry in a text box

k983111

Registered User.
Local time
Today, 22:47
Joined
Aug 21, 2002
Messages
36
I have a form with a text box on it. A number gets entered into this text box by a bar scanner, the problem is a letter Q is entered in front of the number eg. Q288. Is there a quick way to drop or remove this Q before it gets entered into the table without having to write complex functions, etc?
 
What if?

You load the field with the value as text (which it must be if it can hold letters as well as numbers) from the scanner

A hidden field on the form (Textbox2) has a Controlsource of -

=Right$(Textbox1,Len(Textbox1)-1)

This will strip the first character off the string, so that -

Q1234

becomes

1234

and Textbox2 is the field to link to the table.

The only drawback is that Textbox2 will show #ERROR until it's updated.

HTH

Dave E
 
Dave the formula works fine, but how do i link the second text box to the table if its control is the formula.
 
Try this...

Code:
If KeyAscii =113 Then
KeyAscii = 0
End If

If the input from the barcode scanner is regarded as the same as the input from the keyboard then this snippet of code added to your KEYPRESS event will ignore the Q that is passed.
 
Well I'm a silly billy, aren't I?

If you ignore most of what I said before and put the code in the AFTERUPDATE of TEXTBOX1 so that it reads -

Textbox2=Right$(Textbox1,Len(textbox1)-1)


then Textbox2 can have its controlsource from the table.

I apologise for any confusion.

The only problem I can forsee is whether the code will be triggered by the input from the scanner.

Dave E
 
Both solutions work fine, thanks for your help.
 

Users who are viewing this thread

Back
Top Bottom