Need help understanding a (vague) error message

Martao

New member
Local time
Today, 17:33
Joined
Jul 11, 2011
Messages
5
Hello,

I am coding on a vba program to load an XML file into an(other) access 2003 database. I'm putting the data in 4 tables now, which worked fine for the first three tables (using AdoDB.Recordset).
On updating the 4th Recordset Im getting a very vague error. I already toggled all code that manipulated the table to comments, except filling in the primary key. So, basically nothing happens except .Open, .AddNew and . Update.

On recordset.Update I'm getting the following error (1st line translated from Dutch):

"Error -2147217887 (80040e21) during execution:

Invalid Reference test code"

I can't see anything wrong with the code; it's similar to the other tables that worked fine. Unfortunately, Google didnt help me find any lead on the problem. Can anyone help/explain me what the error message should mean?

Here's a small code snippet:

Code:
Dim VisitID As Integer
VisitID = 21
 
Dim dbHFA As New ADODB.Connection
dbHFA.Provider = "Microsoft.Jet.OLEDB.4.0"
dbHFA.Open "hfa.mdb"
 
Dim tableThreshold As New ADODB.Recordset
tableThreshold.Open "Threshold_Test", dbHFA, adOpenDynamic, adLockPessimistic
tableThreshold.AddNew
tableThreshold("VISIT_ID").Value = VisitID
tableThreshold.Update

Thanks in advance!
 
Last edited:
I have no clue what it means, so I would exclude any potential sources for error:

1. What is the data type of VisitID
2. What is its actual value
3. What is the type for field Visit_ID
4. What are the constraints on that field - not null, index, not duplicates allowed , up/down cacade dependencies
 
Ok, sorry, I forgot to mention that I got the same error message when I commented the editting of the VisitID field. SO that doesn't seem to be the source of error IMO.

VISIT_ID is a long integer in the access DB.
It is the primary key of the 'Threshold_Test' table, so yes, it is indexed and no duplicates allowed. I dont know what you mean exactly with the up/down dependencies?

I edited my first post with the declaration and setting the value of the VisitID variable. This value normally comes from another table, but for the sake of debugging I switched all other code off and set it manually.
 
Is the table related to other tables in any way?
Any other fields in the record that have to have a value?
 
Okay, I'm an idiot. The error came from a custom validation on one of the other fields and the default value wasnt valid.
Thanks for somehow pointing me in the right direction.
 
Okay, I'm an idiot. The error came from a custom validation on one of the other fields and the default value wasnt valid.
Thanks for somehow pointing me in the right direction.
 
Throwing :

Error -2147217887 (80040e21)

into Google gives numerous suggestions
 

Users who are viewing this thread

Back
Top Bottom