J
John Nurick
You're setting the starting row
J = 15
*inside* the loop, so each time you go round it undoes the
J = J + 1
at the end of the loop. Should be
...
J = 15
Do Until rst.EOF
IRecords = IRecords + 1
With wbk.Sheets("JournalEntry")
...
End With
rst.MoveNext
J = J + 1
Loop
...
J = 15
*inside* the loop, so each time you go round it undoes the
J = J + 1
at the end of the loop. Should be
...
J = 15
Do Until rst.EOF
IRecords = IRecords + 1
With wbk.Sheets("JournalEntry")
...
End With
rst.MoveNext
J = J + 1
Loop
...
Okay I have stepped through the code and I realized that the results of the
query are overwritting each other until the last record is reached and then
that record is being written to the spreadsheet. I'm not real sure on how to
get all the results of the query to populate in the spreadsheet. Not sure if
I'm missing something that will allow all the results from the query to be
written into spreadsheet in the preceding cells.
Code:Do Until rst.EOF With wbk.Sheets("JournalEntry") J = 15 IRecords = IRecords + 1 .Range("G3") = rst.Fields("BranchNumber").Value .Cells(J, 11).Value = rst.Fields("GL_Acct").Value .Cells(J, 12).Value = rst.Fields("GL_Subacct").Value .Cells(J, 15).Value = rst.Fields("GROSS").Value .Cells(J, 17).Value = rst.Fields("AccountDescription").Value End With J = J + 1 rst.MoveNext Loop [\Code] Any help on how I could accomplish this will be greatly appreciated. Thanks! [QUOTE="John"] There's always a reason. But if you won't step through the code in order to find out where it goes wrong I'm not willing to guess. <snip>[/QUOTE][/QUOTE]