Parsing a textbox entry

G

Guest

I am looking into the feasibility of adding barcode readers into a database
system. I have a form that has three textboxes on it. They are code, lot, and
product. I am looking to create a fourth textbox that the barcode reader will
input to. I was wondering how do I go about setting up the form to parse the
entry of th fourth textbox to populate the other three fields? the first
field will always be 6 characters. The second will always be 10. The third
will be 3 to 5 characters long. I am not very familiar with VBA, so if VBA is
used it will need to be explained.
I thank you for your help.
 
J

John Vinson

I am looking into the feasibility of adding barcode readers into a database
system. I have a form that has three textboxes on it. They are code, lot, and
product. I am looking to create a fourth textbox that the barcode reader will
input to. I was wondering how do I go about setting up the form to parse the
entry of th fourth textbox to populate the other three fields? the first
field will always be 6 characters. The second will always be 10. The third
will be 3 to 5 characters long. I am not very familiar with VBA, so if VBA is
used it will need to be explained.
I thank you for your help.

YOu could use code like this in the AfterUpdate event of the barcode
textbox:

Private Sub txtFourth_AfterUpdate()
If Not IsNull(Me!txtFourth) Then
Me!txtCode = Left(Me!txtFourth, 6)
Me!txtLot = Mid(Me!txtFourth, 7, 10)
Me!txtProduct = Mid(Me!txtFourth, 17)
End If
End Sub

This will pull the first six characters into the textbox txtCode, the
seventh through 16th into txtLot, and the remainder of the field
(however long!) into txtProduct.

You should really do some validity checking (e.g. rather than checking
just for Null to check to see if the length is in fact 20 to 22
characters, that the extracted values are valid, etc.)

John W. Vinson[MVP]
 
G

Guest

This works great, except for one thing. After doing this it goes onto a new
form after entry. I need the focus moved to a subform.
Thank you for your help.
Tyra
 
J

John Vinson

This works great, except for one thing. After doing this it goes onto a new
form after entry. I need the focus moved to a subform.
Thank you for your help.

Right mouseclick the little box at the upper left intersection of the
rulers in form design view, and select "Tab Order". Move the barcode
textbox right before the Subform control in the tab order.

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top