Hi there all,
I am trying to fill an excel sheet from an access recordset, using this code
newdata.MoveFirst
With xlapp
Do Until newdata.EOF
x = x + 1
For y = 1 To 22 ' the recordset has 22 fields
.Worksheets(1).Cells(x, y) = newdata.Fields
.Value
Next y
newdata.MoveNext
Loop
it works fine EXCEPT it ignores the first field in the recordset....field one should go to cell 1, field 2 to cell 2 etc. It seems to move all the cells back one so that field 2 in in cell 1. If I start with y=0 an error occurs.
Any ideas on how to solve this would be much appreciated!
I am trying to fill an excel sheet from an access recordset, using this code
newdata.MoveFirst
With xlapp
Do Until newdata.EOF
x = x + 1
For y = 1 To 22 ' the recordset has 22 fields
.Worksheets(1).Cells(x, y) = newdata.Fields

Next y
newdata.MoveNext
Loop
it works fine EXCEPT it ignores the first field in the recordset....field one should go to cell 1, field 2 to cell 2 etc. It seems to move all the cells back one so that field 2 in in cell 1. If I start with y=0 an error occurs.
Any ideas on how to solve this would be much appreciated!