Access 2003
I'm trying to build a command button to parse each line into a new record of my table [TBLRECORDS]
I am able to parse a single line using this code but don't know how to insert the data into the table and loop through for all lines in my [memFile] control
On a form I have a text control [memFile]
I populate it by pasting text from the body of an email into it and it is stored in a tables memo field [TBLFILES].[TEXTFILE]
Each email can have countless rows of data in this format
H E74 Warranty end not prior to Serv start for XRC Status: M RecordId=897*7756*33*1D1PMB*20140418
H E74 Warranty end not prior to Serv start for XRC Status: M RecordId=897*7916*68*A1C558*20140418
Each line of data will always begin with "H " and each line of text will always have the same character count
For each line in me.memFile I want to create a new table record and populate this way
[TBLRECORDS][TXTTYPE] = strType
[TBLRECORDS][TXTCODE] = strCode
[TBLRECORDS][TXTDESCRIPTION] = strDescription
[TBLRECORDS][TXTRECORD] = strRecord
[TBLRECORDS][TXTMODEL] = strModel
[TBLRECORDS][TXTCOUNTRYCODE] = strCountryCode
[TBLRECORDS][TXTSERIAL] = strSerial
[TBLRECORDS][DTERRORDATA] = strErrorDate
thanks
I'm trying to build a command button to parse each line into a new record of my table [TBLRECORDS]
I am able to parse a single line using this code but don't know how to insert the data into the table and loop through for all lines in my [memFile] control
On a form I have a text control [memFile]
I populate it by pasting text from the body of an email into it and it is stored in a tables memo field [TBLFILES].[TEXTFILE]
Each email can have countless rows of data in this format
H E74 Warranty end not prior to Serv start for XRC Status: M RecordId=897*7756*33*1D1PMB*20140418
H E74 Warranty end not prior to Serv start for XRC Status: M RecordId=897*7916*68*A1C558*20140418
Each line of data will always begin with "H " and each line of text will always have the same character count
For each line in me.memFile I want to create a new table record and populate this way
[TBLRECORDS][TXTTYPE] = strType
[TBLRECORDS][TXTCODE] = strCode
[TBLRECORDS][TXTDESCRIPTION] = strDescription
[TBLRECORDS][TXTRECORD] = strRecord
[TBLRECORDS][TXTMODEL] = strModel
[TBLRECORDS][TXTCOUNTRYCODE] = strCountryCode
[TBLRECORDS][TXTSERIAL] = strSerial
[TBLRECORDS][DTERRORDATA] = strErrorDate
Code:
Private Sub btnParse_Click()
Const strDelimiter As String = "H E74 Warranty end not prior to Serv start for XRC Status: M RecordId=897*7756*33*1D1PMB*20140418" 'This will be replaced by me.memFile
Dim strType As String
Dim strCode As String
Dim strDescription As String
Dim strRecord As String
Dim strModel As String
Dim strCountryCode As String
Dim strSerial As String
Dim strErrorDate As String
strType = Left(strDelimiter, 1)
strCode = Mid(strDelimiter, 6, 3)
strDescription = Mid(strDelimiter, 13, 51)
strRecord = Mid(strDelimiter, 77, 3)
strModel = Mid(strDelimiter, 81, 4)
strCountryCode = Mid(strDelimiter, 86, 2)
strSerial = Mid(strDelimiter, 89, 6)
strErrorDate = Right(strDelimiter, 8)
Debug.Print strType
Debug.Print strCode
Debug.Print strDescription
Debug.Print strRecord
Debug.Print strModel
Debug.Print strCountryCode
Debug.Print strSerial
Debug.Print strErrorDate
End Sub
thanks