One approach is to use a regular expression to identify the first group
of 4 digits in the string. If you copy the rgxExtract function at
http://www.j.nurick.dial.pipex.com/C...rgxExtract.htm into a
code module, you can use something like this, where XXX is a variable
(or in a query, the field) containing the text:
rgxExtract(XXX, "\d{4}")
\d means a digit 0-9, and {4} means four of them, so the expression gets
the first four contiguous digits in the string. E.g. if you give it "xxx
12345 xxx678 xxx9999xxx" it will return "1234".
If necessary one can get much more subtle. For instance this
rgxExtract(XXX, "^(?:.*?\D)?(\d{4})\D")
will get the first substring of exactly 4 digits (in the example above
it skips the 12345 and 678 and returns "9999").
On Tue, 2 May 2006 11:40:02 -0700, The Chomp
<(E-Mail Removed)> wrote:
>Good Afternoon.
>
>This worked great. I diod run into a weeee bit of a problem. It seems that
>there is can be more that one set of numbers in the field (just can't get
>people to enter the right stuff).
>After a review of all the records in the field, it seems that the only
>number I need worry about is the "left most" number.
>Anyone have anything that would help.
>
> Thanks all
>
>"The Chomp" wrote:
>
>> I have a field that contains text and a 4 digit number. the 4 digit number is
>> not always in the same position in the field. What I am trying to do is
>> locate the number in the field and then copy the number only to a new field.
>> The one problem is. The record could look like this " I would like 3434 to be
>> part" or it could look like this "I would like3434 to be part".
>> This is been driving me nuts for a while...
>> Thanks for any help
>>
>>
>>
--
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.