How to find and store 4-digits in a string

I have a Table with 2 fields of different data types:  Location (Text), Date (Date).
Currently, the Date field is empty.
Is there a way to populate the Date field with the 4 numbers contained in the Location field and concatenate "1/1/" before 4 numbers.
The 4 numbers always appear adjacent and can be anywhere within the Location field.
See current state (BEFORE) and desired state (AFTER), below.


ID    Location                                                                                            Date
1      c:\red\white\blue\red1844\green\snack1.doc
2      c:\yellow\green\wheat2015.bmp
3      c:\gr1995een\orange.jpg


ID    Location                                                                                            Date
1      c:\red\white\blue\red1844\green\snack1.doc                           1/1/1844
2      c:\yellow\green\wheat2015.bmp                                                 1/1/2015
3      c:\gr1995een\orange.jpg                                                               1/1/1995
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

This should come close
Function Q_28713755(parmString)
    Static oRE As Object
    Dim oMatches As Object
    If oRE Is Nothing Then
        Set oRE = CreateObject("vbscript.regexp")
        oRE.Global = False
        oRE.Pattern = "\d{4}"
    End If

    If IsNull(parmString) Then
        Q_28713755 = Null
        Exit Function
    End If

    If oRE.test(parmString) Then
        Set oMatches = oRE.Execute(parmString)
        Q_28713755 = DateSerial(oMatches(0), 1, 1)
        Q_28713755 = Null
    End If

End Function

Open in new window

Update Mytable
Set [Date] = Q_28713755([Location])
Where  [Date] Is Not Null

Open in new window

clock1Author Commented:
Thanks for comment, but chose vb script in error.
Bill PrewIT / Software Engineering ConsultantCommented:
Inside the function body, the two lines that have "q =" in them need to be "Q_28713755 =".

Then create that function in the access db, and run the update query.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Thanks, Bill.

I have updated the code.
clock1Author Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.