I have mocked up your general situation. First I parsed your test record to get a list of the fieldnames with Contents.
I included the ":" with the field name to allow further processing.
I put them in a table "Smithfields" as below:
Code:
ID |
Field1 |
1 |
LastName: |
2 |
FirstName: |
3 |
MI: |
4 |
State: |
5 |
Street: |
6 |
City: |
7 |
Zip: |
8 |
County: |
9 |
Employer_Present_Information: |
10 |
DayPhone: |
11 |
EvePhone: |
12 |
Email: |
13 |
BirthDay: |
14 |
Gender: |
15 |
EmergName: |
16 |
EmergRelation: |
17 |
EmerDayPhone: |
18 |
EmerEvePhone: |
19 |
SPNeeds: |
20 |
EmrgInfo: |
21 |
HowHeard: |
22 |
CrseNo1: |
23 |
CrseTitle1: |
24 |
DayTime1: |
25 |
Cost1: |
26 |
CrseNo2: |
27 |
CrseTitle2: |
28 |
DayTime2: |
29 |
Cost2: |
30 |
CrseNo3: |
31 |
CrseTitle3: |
32 |
DayTime3: |
33 |
Cost3: |
34 |
TotalCost: |
35 |
Comments: |
Then I added another record to the "data" and called the table "csmith"
Code:
MyID Auto
Contents Memo
Then played with some vba to
1 --read the Smithfields data into an array
2 --open the Csmith table and process each record, by
3 --parsing the contents, looking for the fieldname and
4--displaying in immediate window the fieldname and value to be inserted into a table
Here is the vba I used
Code:
'---------------------------------------------------------------------------------------
' Procedure : getContents
' Author : mellon
' Date : 03-Mar-2017
' Purpose : This is in responseto post
' https://www.accessforums.net/showthread.php?t=64733&p=349386#post349386
'
'OP (csmith) has outlook data in Access memo field and needs to parse data
' this uses tables csmith ------- the raw data memo field is Contents
' smithFields ---the fields in sequence to be found in Contents
'---------------------------------------------------------------------------------------
'
Sub getContents()
Dim Fldsarr(35) As String 'an array of field names within each Contents field
Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim s As String
Dim str As String
Dim strWork As String
Dim x As Variant
Dim i As Integer
10 On Error GoTo getContents_Error
20 Set db = CurrentDb
30 Set rs = db.OpenRecordset("smithFields")
'routine to put expected field names into an array for processing
40 Do While Not rs.EOF
50 Fldsarr(rs!id) = rs!field1
'Debug.Print Fldsarr(rs!id)
60 rs.MoveNext
70 Loop
'array has been populated
80 rs.Close
90 Set rs = db.OpenRecordset("csmith") 'this is sample records from csmith's post
' made up a second record with mst fields populated
'routine to parse Contents looking for Fieldnames
100 Do While Not rs.EOF
110 str = Replace(rs!Contents, vbCrLf, "")
120 Debug.Print "---------------New record -----------" & vbCrLf
130 For i = 1 To UBound(Fldsarr)
'this logic needed to handle the last field and value in Contents
140 If i < UBound(Fldsarr) Then
'get the start of next name
150 strWork = Mid(str, InStr(str, Fldsarr(i)))
160 s = Left(strWork, InStr(strWork, Fldsarr(i + 1)) - 1)
'Debug.Print s 'for debugging
170 x = Split(s, ":")
180 Debug.Print "insert this value '" & x(1) & "' into the column(" & x(0) & ")"
190 Else
'process the last field
200 strWork = Mid(str, InStr(str, Fldsarr(i)))
210 s = strWork
220 x = Split(s, ":")
230 Debug.Print "insert this value '" & x(1) & "' into the column(" & x(0) & ")"
240 End If
250 Next i
260 rs.MoveNext
270 Loop
280 On Error GoTo 0
290 Exit Sub
getContents_Error:
300 MsgBox "Error " & err.number & " in line " & Erl & " (" & err.Description & ") in procedure getContents of Module AWF_Related"
End Sub
Here is a listing of the output from the test records:
---------------New record -----------
insert this value 'W*****' into the column(LastName)
insert this value 'D****' into the column(FirstName)
insert this value '' into the column(MI)
insert this value 'CA' into the column(State)
insert this value '63**** ***Ct' into the column(Street)
insert this value 'Bl*****' into the column(City)
insert this value '4***1' into the column(Zip)
insert this value 'M*****' into the column(County)
insert this value '' into the column(Employer_Present_Information)
insert this value '81*-***-**75 (could be entered differently, form doesn't have a mask)' into the column(DayPhone)
insert this value '' into the column(EvePhone)
insert this value 'de******@gmail.com' into the column(Email)
insert this value '01/21/****' into the column(BirthDay)
insert this value '' into the column(Gender)
insert this value '' into the column(EmergName)
insert this value '' into the column(EmergRelation)
insert this value '' into the column(EmerDayPhone)
insert this value '' into the column(EmerEvePhone)
insert this value '' into the column(SPNeeds)
insert this value '' into the column(EmrgInfo)
insert this value '' into the column(HowHeard)
insert this value '' into the column(CrseNo1)
insert this value '' into the column(CrseTitle1)
insert this value '' into the column(DayTime1)
insert this value '' into the column(Cost1)
insert this value '' into the column(CrseNo2)
insert this value '' into the column(CrseTitle2)
insert this value '' into the column(DayTime2)
insert this value '' into the column(Cost2)
insert this value '' into the column(CrseNo3)
insert this value '' into the column(CrseTitle3)
insert this value '' into the column(DayTime3)
insert this value '' into the column(Cost3)
insert this value '' into the column(TotalCost)
insert this value '' into the column(Comments)
---------------New record -----------
insert this value 'Williams-Jonstone' into the column(LastName)
insert this value 'Jerimiah' into the column(FirstName)
insert this value 'P' into the column(MI)
insert this value 'WV' into the column(State)
insert this value '278 Greenapple Way' into the column(Street)
insert this value 'Wheeling' into the column(City)
insert this value '42341' into the column(Zip)
insert this value 'Obama' into the column(County)
insert this value 'TJ Maxx Ltd' into the column(Employer_Present_Information)
insert this value '2459872345' into the column(DayPhone)
insert this value '2459872346' into the column(EvePhone)
insert this value 'nonexistent@mymail.net' into the column(Email)
insert this value '24 January 1958' into the column(BirthDay)
insert this value 'M' into the column(Gender)
insert this value 'Mrs. Gladys Knight' into the column(EmergName)
insert this value 'Mother' into the column(EmergRelation)
insert this value '1800CallHome' into the column(EmerDayPhone)
insert this value '1800CallHome' into the column(EmerEvePhone)
insert this value 'Peanut allergyLactose intolerant' into the column(SPNeeds)
insert this value 'Hates Peanuts' into the column(EmrgInfo)
insert this value 'Television' into the column(HowHeard)
insert this value 'Myth101' into the column(CrseNo1)
insert this value 'Ancient Greek Mythology' into the column(CrseTitle1)
insert this value 'Tues 7-8AM' into the column(DayTime1)
insert this value '$400' into the column(Cost1)
insert this value '007' into the column(CrseNo2)
insert this value 'Mental Anguish' into the column(CrseTitle2)
insert this value 'Mon 9-10 AM' into the column(DayTime2)
insert this value '0' into the column(Cost2)
insert this value '2345' into the column(CrseNo3)
insert this value 'Intro to Arithmetic' into the column(CrseTitle3)
insert this value 'Wed 6-8 PM' into the column(DayTime3)
insert this value '23.68' into the column(Cost3)
insert this value '423.68' into the column(TotalCost)
insert this value 'This is a meaningless, nonsensical bit of freeform text to fill and test this long text(memo field) to show something in this option.' into the column(Comments)
I know others have answered, but thought another approach may be helpful.
Good luck with your project.