air1access
Technical User
I have a piece of code I'm messing with to normalize a recordset.
I'm trying to get the field name of rs1 and add it as a value for rs2.
I have a tried a few things, but can quite get it....
Any suggestions?
Thanks in advance..!!
I'm trying to get the field name of rs1 and add it as a value for rs2.
I have a tried a few things, but can quite get it....
Any suggestions?
Thanks in advance..!!
Code:
Dim db As Database
Dim rs1 As Recordset
Dim rs2 As Recordset
Dim FieldCount As Integer, i As Integer
Dim fld As Field
FieldCount = 7
Set db = CurrentDb
Set rs1 = db.OpenRecordset("Table2") 'table with denormalized format
Set rs2 = db.OpenRecordset("table1") 'table with normalized format
rs1.MoveFirst
Do While Not rs1.EOF
For i = 1 To FieldCount - 1
If Not IsNull(rs1("Value" & i)) Then
rs2.AddNew
rs2!Assigned_Resource = rs1!Assigned_Resource
[highlight #F57900]rs2!Fld_Name = rs1.Fields.Name[/highlight]
rs2!ValueNo = rs1("Value" & i)
rs2.Update
End If
Next i
rs1.MoveNext
Loop