Parsing

P

Peter

Could someone please point me to a function/module for Access 2000 that will
enable me to parse a string field. So if a field consists of "word_1
word_2 ......word_n", I would like to be able to select either the first or
the last or any number of consecutive words from the middle (similar to the
'mid' function for characters).

Many thanks
 
A

Allen Browne

Use the Split() function to break the words into an array.

Then LBound() gives you the first word, UBound() the last, or you can get
the nth element of the array for anything in between.
 
P

Peter

Thanks, but I do not seem to have Split in Access 2000. Is there another
way or can I import it form somewhere?

Peter
 
D

Douglas J. Steele

Split was introduced in Access 2000, but there was a problem using it in
queries initially. (In VBA, though, there shouldn't be any problem). Make
sure you've got all of the service packs installed. Also, you might want to
check your References collection, just in case that's why you can't get the
function to work.

References problems can be caused by differences in either the location or
file version of certain files between the machine where the application was
developed, and where it's being run (or the file missing completely from the
target machine). Such differences are common when new software is installed.

On the machine(s) where it's not working, open any code module. Select Tools
| References from the menu bar. Examine all of the selected references.

If any of the selected references have "MISSING:" in front of them, unselect
them, and back out of the dialog. If you really need the reference(s) you
just unselected (you can tell by doing a Compile All Modules), go back in
and reselect them.

If none have "MISSING:", select an additional reference at random, back out
of the dialog, then go back in and unselect the reference you just added. If
that doesn't solve the problem, try to unselect as many of the selected
references as you can (Access may not let you unselect them all), back out
of the dialog, then go back in and reselect the references you just
unselected. (NOTE: write down what the references are before you delete
them, because they'll be in a different order when you go back in)
 
A

Allen Browne

Peter, by posting separate threads, you are getting fragmented discussion.
See the replies in comp.databases.ms-access
 
A

Albert D.Kallal

As mentioned, the split command should do the tick.

debug.print split("one/two/three","/")(0)

The above would fetch the first token..and display 'one'

You can use whatever delimiter you want....
 
P

Peter

Thanks Allen - yes I have read the useful stuff there. It is interesting
that the same question has given rise to two such different threads, both
illuminating.

Peter
 
Top