I have searched on stackoverflow for this error message but none of the other situations/answers apply to me: every table in the database has a Primary Key, the database has no linked tables, and the queries are very simple. What's more, and possibly more significant, the queries usually work but sometimes don't; if a query fails then I usually try again (almost immediately) and then it usually works (and if it doesn't, I just retry several times and eventually it works again).
Here is just one example of the type of query I am using:
INSERT INTO GbpEx (GbpExDate,Currency,CurrencyID,GbpExRate) VALUES (43131,2,1,1331)
So it is very simple, no subqueries, and no linked tables. The table GbpEx has a primary key (all of my tables have a PK). And the query usually works but sometimes doesn't.
It isn't just INSERT; UPDATE queries also fail (and then work again moments later).
Here is my setup: I have an Excel application that connects to an Access database over a network. The Access database is not split, and contains Tables and Queries only -- no macros, no VBA, nothing. When the user starts the Excel app, the first thing the app does is write to the database with an UPDATE to make a note of when the user started the app. Usually this works just fine and the user can go ahead and use the app; sometimes this UPDATE fails (with the error message above), so the user tries two or three times and eventually there is no error and the app works as expected. Sometimes, the app fails in mid-operation (using a different query, for example the one above) with the error and the app stops; then the user tries again and all is well.
There are typically about 10 users, and maximum I have ever seen is about 20. Every time the app wants to interact with the database, it establishes a connection, performs its interaction, then closes the connection -- I close the connection as soon as possible so as to reduce the load on the database and the network.
I'm afraid I cannot reliably reproduce the error.
Here is another point: I thought it might be some sort of temporary read-only setting in the database, so I tried making the Access accdb file read-only. When I step through and the execution enters my error handling routine the error is the same as the one listed above, but there is an important difference: my error handling routine also writes to the database and so enters an infinite loop. However with the normal error it does not enter an infinite loop, so if the problem is because of the Access accdb file becoming read-only, it is for a fraction of a second (ie it becomes writeable by the time execution enters the error handler).
Before someone suggests SQL Server and the like -- yes, we have plans to migrate in the near future, but not just yet. And I would like to make sure that this problem will not carry over to another database.
Does anyone have any ideas please?
EDIT: Some more things I should mention:
This Excel app has been working just fine for several months and has only just (in the last couple of weeks) started displaying this behaviour. We also had to contend with the error Query '' is corrupt
that was apparently caused by a Windows update in late November but we used Repair on Office and it went away (I suspect we did that at the precise moment that MS fixed the problem).
I have also tried the DISTINCTROW
approach but that didn't fix it.
I have to emphasise that all of the INSERTs and UPDATEs are very simply and directly edit a Table -- no linked tables, no subqueries involved at all, no INNER JOIN
, nothing. And they work most of the time and fail just sometimes.