Parsing data from a text field

  • Thread starter Thread starter AJ
  • Start date Start date
A

AJ

I am not much of a programmer, and have been given a database, withwhich to
make some reports.
How would I parse specific numbers from a field that has

Value: 45 Name: RegFee, Value: -3 Name: RegFee, Value: 265 Name: RegProg,
Value: -5 Name: CSSAMem

....all in one field.

I am trying to pull a figure from name/value pair into a separate report
field, so I can sum and check totals, etc. Maybe have 4 or 5 different
fields that will all try to parse something different.

Thanks in advance.

- aj
 
AJ said:
I am not much of a programmer, and have been given a database, withwhich to
make some reports.
How would I parse specific numbers from a field that has

Value: 45 Name: RegFee, Value: -3 Name: RegFee, Value: 265 Name: RegProg,
Value: -5 Name: CSSAMem

...all in one field.
What - all of that text shown above is in one field - or just the "Value: 45
Name: RegFee," parts in each?
I am trying to pull a figure from name/value pair into a separate report
field, so I can sum and check totals, etc. Maybe have 4 or 5 different
fields that will all try to parse something different.

Well - I suppose where you eventually want to output the answers can be
dealt with after you've successfully parsed out the information you want.
:-)

Either way I'd say you'd be well off making the InStr function your good
friend (hmm along with len and probably mid and do/until) :-)
You'd use it to look for "Name" or "Value" in your main text string -
examine the text after that until you encounter a comma (I presume just from
looking at it what's there) and then start from that point searching again.
Have a little look and play - and just ask if you need something a little
more concrete :-)


BFN
 
The other function you may want to look at is Split. Hopefully, the
first pair's missing comma is just a typo. If so, you could split your
data into an array, and then split those again. Read up on split in
the VB Help and play with it a little. If you can read the separate
variable/value pairs into an array (and the format is consistent), you
can create a simple rule to split the two and write them to separate
fields in your table. (for that see recordsets and .AddNew)
 
Back
Top