I have a sanitized database which I have attached, and for the most part transposes the data to my liking. There is however a few issues that I would like to fix, but cannot determine the problem in my code. Basically, the text field AccountNumber is being recognized as data, along with the account numbers and classes being populated incorrectly. If you run the attachment you will see my error. I appreciate anyones help in this matter. Thank you.
Code:
Function test() Dim i As Integer, x As Integer Dim rs As Recordset, rs2 As Recordset Set rs = CurrentDb.OpenRecordset("table1", dbOpenDynaset) Set rs2 = CurrentDb.OpenRecordset("newtable", dbOpenDynaset) With rs .MoveLast .MoveFirst End With With rs2 x = 1 Do Until rs.EOF Do Until x = rs.Fields.Count .AddNew !Date = rs.Fields(0) !AccountNumber = rs.Fields(x).Name !ClassNumber = rs.Fields(x) !Percent = rs.Fields(x) .Update x = x + 1 Loop x = 1 rs.MoveNext Loop rs.Close .Close End With Set rs = Nothing Set rs2 = Nothing End Function
Comment