Run-time error '3021:

cstimart

Well-known Member
Joined
Feb 25, 2010
Messages
1,180
I am getting using ADO to push excel data into Access and get the following error upon hitting the first record/cell.

"Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record."

This is the section of code that is hanging...

Code:
    For i = 2 To Rw
        For j = 1 To 31
            If Len(Cells(i, j).Value) > 0 Then
                [COLOR=Red]rst(Cells(1, j).Value) = Cells(i, j).Value[/COLOR]
            End If
        Next j
        rst.Update
    Next i
The value in Cell A2 is 108011385 and the table/column is "adDouble"

Any ideas?
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
I think you need to add a new record first and specify the field you're updating. I'm assuming that the header row has the field names.
Code:
    For i = 2 To Rw
        [COLOR=red]rst.addnew[/COLOR]
        For j = 1 To 31
            If Len(Cells(i, j).Value) > 0 Then
                rst.[COLOR=red]fields[/COLOR](Cells(1, j).Value) = Cells(i, j).Value
            End If
        Next j
        rst.Update
    Next i
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,834
Members
452,947
Latest member
Gerry_F

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