G
GLT
Hi Gents,
Thanks for your reply - I have each text file loaded into a memo feild and
then read the memo feild line by line, and extract the feild information from
each line into a new table.
I then scan the table and insert three unique values for each set of data:
(1) JobNo, (2) Session No (3) Workstation ID - this allows each record to be
unique.
I thought that maybe at this point (because I can identify each record
uniquely), I might be able to use SQL to load into a new table, but this also
will not work.
So now I am trying to read each line, check what the feild is and then
insert feild value in a new record. Each Set of data begins at the Job No
record, so i am trying to loop through the data (and update each feild in the
new table) until it hits a new Job no, then repeats this process over again...
This is the code that I am using to try to acheive this:
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim rst1 As DAO.Recordset
Dim strDate As String
Dim strFileNo As String
Dim strFeild1 As String
Dim strFeild2 As String
Set db = CurrentDb()
Set rst = CurrentDb.OpenRecordset("tbl_ParsedLogFileDetails")
Set rst1 = CurrentDb.OpenRecordset("tbl_BackupLogStats")
If rst.RecordCount = 0 Then
'rst.Close
Set rst = Nothing
Set db = Nothing
Else
With rst
.MoveLast
.MoveFirst
With rst1
Do Until rst.EOF
strDate = rst!DateStamp
strFileNo = rst![FileNo]
strFeild1 = rst![Feild1]
strFeild2 = rst![Feild2]
Debug.Print rst![Session] & " " & rst![JobNo]
If strFeild1 = "Session" Then
rst1.Edit
rst1![Session] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Job No" Then
rst1.AddNew
rst1![FileNo] = rst![FileNo]
rst1![DateStamp] = rst![DateStamp]
rst1![JobNo] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Job ID" Then
rst1.AddNew
rst1![Job ID] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Description" Then
rst1.Edit
rst1![Description] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Workstation" Then
rst1.Edit
rst1![Workstation] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Source" Then
rst1.Edit
rst1![Source] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Target" Then
rst1.Edit
rst1![Target] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Start Time" Then
rst1.Edit
rst1![Start Time] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Total Directories" Then
rst1.Edit
rst1![Total Directories] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Total File(s)" Then
rst1.Edit
rst1![Total File(s)] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Total Skip(s)" Then
rst1.Edit
rst1![Total Skip(s)] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Total Size (Disk)" Then
rst1.Edit
rst1![Total Size (Disk)] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Total Size (Media)" Then
rst1.Edit
rst1![Total Size (Media)] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Elapsed Time" Then
rst1.Edit
rst1![Elapsed Time] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Session Status" Then
rst1.Edit
rst1![Session Status] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Average Throughput" Then
rst1.Edit
rst1![Average Throughput] = strFeild2
rst1.Update
rst.MoveNext
If rst![Feild1] = "Total Error(s)/Warning(s)" Then
rst1.Edit
rst1![Total Error(s)/Warning(s)] = strFeild2
rst1.Update
ElseIf rst![Feild1] = "Job No" Then
rst1.Update
rst.MovePrevious
End If
Else
rst.MoveNext
End If
Loop
End With
End With
rst.Close
rst1.Close
End If
I'm still working / testing the above code - if you know of any better ways
to acheive this then Im all ears...
Cheers,
GLT
The
Thanks for your reply - I have each text file loaded into a memo feild and
then read the memo feild line by line, and extract the feild information from
each line into a new table.
I then scan the table and insert three unique values for each set of data:
(1) JobNo, (2) Session No (3) Workstation ID - this allows each record to be
unique.
I thought that maybe at this point (because I can identify each record
uniquely), I might be able to use SQL to load into a new table, but this also
will not work.
So now I am trying to read each line, check what the feild is and then
insert feild value in a new record. Each Set of data begins at the Job No
record, so i am trying to loop through the data (and update each feild in the
new table) until it hits a new Job no, then repeats this process over again...
This is the code that I am using to try to acheive this:
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim rst1 As DAO.Recordset
Dim strDate As String
Dim strFileNo As String
Dim strFeild1 As String
Dim strFeild2 As String
Set db = CurrentDb()
Set rst = CurrentDb.OpenRecordset("tbl_ParsedLogFileDetails")
Set rst1 = CurrentDb.OpenRecordset("tbl_BackupLogStats")
If rst.RecordCount = 0 Then
'rst.Close
Set rst = Nothing
Set db = Nothing
Else
With rst
.MoveLast
.MoveFirst
With rst1
Do Until rst.EOF
strDate = rst!DateStamp
strFileNo = rst![FileNo]
strFeild1 = rst![Feild1]
strFeild2 = rst![Feild2]
Debug.Print rst![Session] & " " & rst![JobNo]
If strFeild1 = "Session" Then
rst1.Edit
rst1![Session] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Job No" Then
rst1.AddNew
rst1![FileNo] = rst![FileNo]
rst1![DateStamp] = rst![DateStamp]
rst1![JobNo] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Job ID" Then
rst1.AddNew
rst1![Job ID] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Description" Then
rst1.Edit
rst1![Description] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Workstation" Then
rst1.Edit
rst1![Workstation] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Source" Then
rst1.Edit
rst1![Source] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Target" Then
rst1.Edit
rst1![Target] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Start Time" Then
rst1.Edit
rst1![Start Time] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Total Directories" Then
rst1.Edit
rst1![Total Directories] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Total File(s)" Then
rst1.Edit
rst1![Total File(s)] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Total Skip(s)" Then
rst1.Edit
rst1![Total Skip(s)] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Total Size (Disk)" Then
rst1.Edit
rst1![Total Size (Disk)] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Total Size (Media)" Then
rst1.Edit
rst1![Total Size (Media)] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Elapsed Time" Then
rst1.Edit
rst1![Elapsed Time] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Session Status" Then
rst1.Edit
rst1![Session Status] = strFeild2
rst1.Update
rst.MoveNext
ElseIf strFeild1 = "Average Throughput" Then
rst1.Edit
rst1![Average Throughput] = strFeild2
rst1.Update
rst.MoveNext
If rst![Feild1] = "Total Error(s)/Warning(s)" Then
rst1.Edit
rst1![Total Error(s)/Warning(s)] = strFeild2
rst1.Update
ElseIf rst![Feild1] = "Job No" Then
rst1.Update
rst.MovePrevious
End If
Else
rst.MoveNext
End If
Loop
End With
End With
rst.Close
rst1.Close
End If
I'm still working / testing the above code - if you know of any better ways
to acheive this then Im all ears...
Cheers,
GLT
The