E
ET
Hi, I need help with run time errors.
The application is running on Access 2002.
It is recordset, loops the records from query, one by one row,
in ADO it gives error 80040e21, invalid argument, -2147217887,
the same code but adjusted for DAO gives the following error:
run time error '3001', invalid argument.
Here is the code for DAO:
=======================
------------------------------------------------
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
strSQL = "SELECT " & _ and bla, bla, bla... SQL code goes after
this line...
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strSQL)
------------------------------------------------
.... basically, the SQL query will pull records from 2 tables, by
matching
their IDs which should be identical, and then VBA code will try to
match
the records based on Item Description field (string), that Description
will be first copied to 2 arrays of strings (WORDS_TB and WORDS_WO
bellow):
(more code for DAO):
------------------------------------------------
If CountWordsInTB = 1 And CountWordsInWO = 2 Then
If WORDS_TB(0) = WORDS_WO(0) Or WORDS_TB(0) = WORDS_WO(1) Then
With rst
.Edit
!FILTER = "OK"
.Update
.Bookmark = .LastModified
End With
NumOfOK = NumOfOK + 1
GoTo lastline
End If
End If
------------------------------------------------
The error message in DAO always comes on the line with .Update
It chokes on something, don't know what and why,
if there are 20,000 records to be updated, it might give error on
the record number 99, but if query sorts records by IDs,
then it gives error on record 2730...
<><><><><><><><><><><><><><><><>
<><><><><><><><><><><><><><><><>
ADO error message:
=======================
The error message with ADO is diferent...
It always points on the line rst.MoveNext
which is located, naturally, at the end of the loop,
right before "Loop" command:
Here is ADO code:
------------------------------------------------
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenDynamic
rst.LockType = adLockOptimistic
rst.Open ("SELECT " & _... bla, bla, the SQL query is identical
with query in ADO...
------------------------------------------------
.... then, Item Description fields from both tables go to String array
named WORDS_TB and WORDS_WO, and there are many if statements
that try to compare description, if it matches it will set the FILTER
field to "OK":
------------------------------------------------
If CountWordsInTB = 1 And CountWordsInWO = 2 Then
If WORDS_TB(0) = WORDS_WO(0) Or WORDS_TB(0) = WORDS_WO(1) Then
rst("FILTER") = "OK"
NumOfOK = NumOfOK + 1
GoTo lastline
End If
End If
------------------------------------------------
In this ADO case, the command "GoTo lastline"
points to the code:
------------------------------------------------
lastline:
DoEvents
updateCount = updateCount + 1
Me.Label11.Caption = updateCount
Me.Label14.Caption = NumOfOK
Me.Label15.Caption = GP_NUM_1
Me.Label17.Caption = GP_NUM_2
DoEvents
rst.MoveNext
------------------------------------------------
The error in ADO always come on the line "rst.MoveNext".
And it comes on different record then in DAO...
In DAO it was 2730 and in ADO it was on 3442 record, with the same sort
order in query...
This is valid for about 20,000 records, which is smaller amount of data
set up just for testing...
But, with real data, which has around 680,000 records, the ADO code
gives error on the line 363,872...
I don't know what else to add... please help, I tried even Repair
option for MS office
on "Add or Remove programs" in Control Panel...
actually, I had to do Repair because yesterday Access couldn't save
the simplies SELECT query, it give error... after repair it was fine.
Thank you!
The application is running on Access 2002.
It is recordset, loops the records from query, one by one row,
in ADO it gives error 80040e21, invalid argument, -2147217887,
the same code but adjusted for DAO gives the following error:
run time error '3001', invalid argument.
Here is the code for DAO:
=======================
------------------------------------------------
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
strSQL = "SELECT " & _ and bla, bla, bla... SQL code goes after
this line...
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strSQL)
------------------------------------------------
.... basically, the SQL query will pull records from 2 tables, by
matching
their IDs which should be identical, and then VBA code will try to
match
the records based on Item Description field (string), that Description
will be first copied to 2 arrays of strings (WORDS_TB and WORDS_WO
bellow):
(more code for DAO):
------------------------------------------------
If CountWordsInTB = 1 And CountWordsInWO = 2 Then
If WORDS_TB(0) = WORDS_WO(0) Or WORDS_TB(0) = WORDS_WO(1) Then
With rst
.Edit
!FILTER = "OK"
.Update
.Bookmark = .LastModified
End With
NumOfOK = NumOfOK + 1
GoTo lastline
End If
End If
------------------------------------------------
The error message in DAO always comes on the line with .Update
It chokes on something, don't know what and why,
if there are 20,000 records to be updated, it might give error on
the record number 99, but if query sorts records by IDs,
then it gives error on record 2730...
<><><><><><><><><><><><><><><><>
<><><><><><><><><><><><><><><><>
ADO error message:
=======================
The error message with ADO is diferent...
It always points on the line rst.MoveNext
which is located, naturally, at the end of the loop,
right before "Loop" command:
Here is ADO code:
------------------------------------------------
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenDynamic
rst.LockType = adLockOptimistic
rst.Open ("SELECT " & _... bla, bla, the SQL query is identical
with query in ADO...
------------------------------------------------
.... then, Item Description fields from both tables go to String array
named WORDS_TB and WORDS_WO, and there are many if statements
that try to compare description, if it matches it will set the FILTER
field to "OK":
------------------------------------------------
If CountWordsInTB = 1 And CountWordsInWO = 2 Then
If WORDS_TB(0) = WORDS_WO(0) Or WORDS_TB(0) = WORDS_WO(1) Then
rst("FILTER") = "OK"
NumOfOK = NumOfOK + 1
GoTo lastline
End If
End If
------------------------------------------------
In this ADO case, the command "GoTo lastline"
points to the code:
------------------------------------------------
lastline:
DoEvents
updateCount = updateCount + 1
Me.Label11.Caption = updateCount
Me.Label14.Caption = NumOfOK
Me.Label15.Caption = GP_NUM_1
Me.Label17.Caption = GP_NUM_2
DoEvents
rst.MoveNext
------------------------------------------------
The error in ADO always come on the line "rst.MoveNext".
And it comes on different record then in DAO...
In DAO it was 2730 and in ADO it was on 3442 record, with the same sort
order in query...
This is valid for about 20,000 records, which is smaller amount of data
set up just for testing...
But, with real data, which has around 680,000 records, the ADO code
gives error on the line 363,872...
I don't know what else to add... please help, I tried even Repair
option for MS office
on "Add or Remove programs" in Control Panel...
actually, I had to do Repair because yesterday Access couldn't save
the simplies SELECT query, it give error... after repair it was fine.
Thank you!