Parse Data from one field into many

detrie

Registered User.
Local time
Yesterday, 21:01
Joined
Feb 9, 2006
Messages
113
Hi All,

Can someone get me started in the right direction?

I have an unbound field on a form "txtScan". This field is populated by a barcode scanner.

The data looks like this ~Field1~Field2~Field3~Field4~Field5~Field6~Field7~Field8~Field9
I am using ~ as a delimiter. Since I am encrypting the barcode, I can pretty much do anything to the barcode.

I need to parse
~Field1~ into txtFirstName
~Field2~ into txtLastName
~Field3~ into txtCompany etc.
A key point is that one of the fields may be blank so, if field 2 in the string is blank, "Field2" does not get populated.

I've never tackled anything like this before and don't know where to start.

Any help
TIA
 
Does the delimiter get placed even if the field is blank (the way most delimited fields do?)

If so, you can just use the split function:
Code:
Dim varFields As Variant
Dim strTxtScan
strTxtScan = Me.txtScan
varFields = Split(strTxtScan, "~" , , vbTextCompare)

Field1 = varFields(0)
Field2 = varFields(1)
etc.
 
Hi Bob,
THANK YOU for the quick reply.
That nailed it for me.
The delimiter DOES indeed get placed for a blank field.
I tested with a blank field and it all worked great!
Thank you again
 

Users who are viewing this thread

Back
Top Bottom