I have an extremely sloppy table I need to clean up.
The first two fields are the origin file and the origin worksheet of an Excel import.
The next fields are often, but not always blank, fields that I need to consolidate into a SINGLE field. In other words...
OriginFile
OriginWorksheet
F1
F2
F3
F4
F5
F????
Becomes:
ConvertFile
ConvertWorkSheet
ConvertF
My problem is that the output is becoming way larger than it should be.
Any ideas?
Thanks!
The first two fields are the origin file and the origin worksheet of an Excel import.
The next fields are often, but not always blank, fields that I need to consolidate into a SINGLE field. In other words...
OriginFile
OriginWorksheet
F1
F2
F3
F4
F5
F????
Becomes:
ConvertFile
ConvertWorkSheet
ConvertF
Code:
Dim strUpdate, strField As String
Dim i As Long
With CurrentDb.OpenRecordset("Select * From Raw2", dbOpenSnapshot)
.MoveFirst
Do While Not .EOF
For i = 2 To .Fields.Count - 1
If Nz(.Fields(i).Value, "") <> "" Then
strField = .Fields(i).Name
strUpdate = "Insert Into Raw2Convert (ConvertFile, ConvertWorksheet, ConvertF) " _
& "SELECT OriginFile, OriginWorksheet, " & strField & " FROM Raw2 WHERE " & strField & " is not null;"
CurrentDb.Execute strUpdate, dbFailOnError
End If
Next
.MoveNext
Loop
End With
My problem is that the output is becoming way larger than it should be.
Any ideas?
Thanks!