Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15583

Runtime error 3021 of last acces row in table is not the selection value

$
0
0
Hello,

I'm running into what I find to be a peculiar issue.

Im using a script to run down my acces DB file in order create a list of cases found within the db based on the value of a field.

I can post the whole code, it involves multiple marcos that call based on arguments, would make the code not very accessible.

The bit that causes the error is;

Public Sub AdoxADANDdateperticker(ByVal Index_Type As String, ByVal strfilepath As String, ByVal strfilename As String)

Dim adoconn As ADODB.Connection
Dim adors As ADODB.Recordset
Dim adorsAD As ADODB.Recordset
Dim sqlAD, sqlDPT, filenm, listT_ID, Assetclass As String
Dim x As Integer
Dim xlshtTD As Excel.Worksheet
Set xlshtTD = Sheets("TickDate")

'>> Stap 2; verwijder van aanwezige data en worksheet voorbereiden

Sheets("TickDate").Select
Columns("A:H").Select
Selection.Delete
xlshtTD.Cells(1, 1).Value = "Counter"
xlshtTD.Cells(1, 2).Value = "Ticker_ID"
xlshtTD.Cells(1, 3).Value = "Latest_Date"
xlshtTD.Cells(1, 4).Value = "Link"


'>> Stap 3: Connectie opbouwen.

sqlAD = "Select * from [Asset_Data]"
sqlDPT = "Select * from [qry_Dateperticker]"
filenm = strfilepath & strfilename
Assetclass = Index_Type

Set adoconn = New ADODB.Connection

adoconn.Open "PROVIDER=MICROSOFT.ACE.OLEDB.12.0;Data Source=" & filenm & ";", "", ""
Set adorsAD = New ADODB.Recordset
adorsAD.Open sqlAD, adoconn

'>> Stap 4: Asset_Data openen en alle assets eruit halen.

x = 2
adorsAD.MoveFirst

Do While Not adorsAD.EOF

While Assetclass <> adorsAD.Fields("Geo_market").Value
adorsAD.MoveNext
Wend

xlshtTD.Cells(x, 2).Value = adorsAD.Fields("Ticker_ID")
xlshtTD.Cells(x, 4).Value = adorsAD.Fields("link")
adorsAD.MoveNext
x = x + 1

Loop

etc.



So when I run my db code, I get a runtime error 3021, BOF or EOF is true. the current record is removed. For the operation there has to be a current record (sorry had to translate from my native language).

Now there are 2 flavors in my database. and I have two versions of scripts; both identical, only the flavor differs. If I run flavor A, while the last row in the [Asset_data] table is the other flavor, I get the message. If I change the flavor of the last row in the table to flavor A, no issues. Same goes when I play around with flavor B. If I make the last Row in the acces table a new flavor C, none of the scripts work.

Why does this happen and how can I fix this?

Thank you for replying!

Viewing all articles
Browse latest Browse all 15583

Trending Articles