Kirk, this is aircode, but see if it illustrates the concept of appending
records, field by field.
It assumes the source table is as you describe, and the target table exists
with the 3 fields you asked for. It loops through the fields from the 2nd
one (the Fields collection is zero-based), inserting records containing the
Func field, then the name of the field, then the value of the field.
Non-normalized data usually contains lots of Nulls, so I assume you want
these filtered out.
Function FixMyData()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim strSql As String
Dim strField As String
Dim i As Integer
Const strcSourceTable = "Table1"
Const strcTargetTable = "Table2"
Set db = CurrentDb()
Set tdf = db.TableDefs(strcSourceTable)
For i = 1 To tdf.Fields.Count - 1
strField = tdf.Fields(i)
strSql = "SELECT INTO " & strcTargetTable & _
" (Func, Prod, Amount) SELECT Func, """ & _
strField & """ AS Prod, [" & strField & _
"] AS Amount FROM " & strcSourceTable & _
" WHERE [" & strField & "] Is Not Null;"
db.Execute strSql, dbFailOnError
Debug.Print db.RecordsAffected & " record(s) for " & strField
Next
Set tdf = Nothing
Set db = Nothing
End Function