Help with looping/dumping recordset

jsabo

New Member
Joined
May 27, 2014
Messages
17
Hey guys,

Have a feeling I'm over-complicating this one... I just want to loop through three different recordsets and dump one field.

I have the loop so it begins at i = 7, so we start at range B7 and move down to B8, and so on until we have moved down the number of records. please let me know if I can clarify:

Code:
Dim i As Integer
Dim j As Integer
Dim k As Integer

recset_cost_comments.MoveFirst
recset_quality_comments.MoveFirst
recset_schedule_comments.MoveFirst

i = recset_cost_comments.RecordCount
j = recset_quality_comments.RecordCount
k = recset_schedule_comments.RecordCount

Do While Not recset_cost_comments.EOF
For i = 7 To (7 + i)
    ActiveWorkbook.Sheets("Cost").Range("B" & i).Value = recset_cost_comments!Comments
    recset_cost_comments.MoveNext
Next i
Loop

Do While Not recset_quality_comments.EOF
For j = 7 To (7 + i)
    ActiveWorkbook.Sheets("Quality").Range("B" & i).Value = recset_quality_comments!Comments
    recset_quality_comments.MoveNext
Next j
Loop

Do While Not recset_schedule_comments.EOF
For k = 7 To (7 + i)
    ActiveWorkbook.Sheets("Schedule").Range("B" & i).Value = recset_schedule_comments!Comments
    recset_schedule_comments.MoveNext
Next k
Loop


The error I get is, "Either BOF or EOF is True, or the current record has been deleted". However, there is one record for the first recordset, 5 for the 2nd and 4 for the 3rd. To note, it does successfully write the one record before kicking out the error.

Any ideas? Thanks.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,221,869
Messages
6,162,530
Members
451,773
Latest member
ssmith04

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top