0

I'm using an MS Access (2010) database for semi-critical data management for my department. It's currently small, ~137 MB, and the queries I'm running are pretty simple, mostly just joins to combine multiple data sources.

I'm running into several types of intermittent errors, where a query function will work fine at first, but on subsequent runs, without my changing anything, it will fail. Sometimes it will start working again.

Most recently, I have a query that runs fine that I export to Excel. During the same Access session, it will work the first time, but then return an "object invalid or no longer set" error when I try to export it a second time. It works again after closing and re-opening the database. This is just one example.

I'm becoming concerned that Access may be a danger to my data, to the point I'm not comfortable continuing to use it. Is this sort of behavior typical of Access, and does it result in data loss or corruption?

Edit to add query code for the example issue. This is actually set up as a series of Access queries, the SQL of which are:

Final query =

SELECT DISTINCT Var1, Var2, ...VarX
FROM Query1 
LEFT JOIN Union_query 
    ON (Query1.DOB = Union_query.DOB) 
    AND (Query1.FST_NM = Union_query.FST_NM) 
    AND (Query1.LST_NM = Union_query.LST_NM);

Query 1 =

SELECT *
FROM ROSTER_LATEST 
INNER JOIN (SELECT max(UPDATE_DATE) AS LAST_DATE, SUB_ID 
FROM ROSTER_LATEST GROUP BY SUB_ID)  
    AS GRAB_DATE 
    ON (ROSTER_LATEST.SUB_ID = GRAB_DATE.SUB_ID) 
    AND (_ROSTER_LATEST.UPDATE_DATE = GRAB_DATE.LAST_DATE);

Union Query =

SELECT *
FROM Query2
UNION 
SELECT *
from Query3;

Query 2 =

SELECT Var1, Var2, ...VarX
FROM All_FHP 
INNER JOIN Query1 
    ON (All_FHP.Date_of_Birth = Query1.DOB) 
    AND (All_FHP.Last_Name = Query1.LST_NM) 
    AND (All_FHP.First_Name = Query1.FST_NM);

Query 3 =

SELECT Var1, Var2, ...VarX
FROM CBP_LIST 
INNER JOIN Query1 
    ON (CBP_LIST.Date_of_Birth = Query1.DOB) 
    AND (CBP_LIST.Last_Name = Query1.LST_NM) 
    AND (CBP_LIST.First_Name = Query1.FST_NM);
Rominus
  • 1,181
  • 2
  • 14
  • 29
  • Do you use VBA code extensively? Are you using global DAO Objects for your recordsets and querydefs? Have you split your database into a front-end for code and backend for data? Do you make frequent changes that get distributed out to users? – dbmitch Jul 29 '16 at 16:15
  • @dbmitch no to all of those – Rominus Jul 29 '16 at 16:20
  • Is the database stored in a shared folder? If so, is it ever opened by more than one user at the same time? Also, is the shared folder located on a real Windows machine, or is it on a NAS device or some other storage appliance? – Gord Thompson Jul 29 '16 at 16:26
  • If you have multiple users the database should be split, so each user has their own front-end. What is your `query function`? Your export error sounds like a VBA error. – dbmitch Jul 29 '16 at 16:34
  • @GordThompson It is in a shared folder, but is not opened by anyone but me. I'm not sure how our server is set up regarding your second question. – Rominus Jul 29 '16 at 17:36
  • @dbmitch added the query code to the question – Rominus Jul 29 '16 at 18:02
  • 1
    Do you use VBA at all? Because *"object invalid or no longer set"* is a VBA error. Either a bug in your code, or the code was stopped inbetween and object variables were reset. – Andre Jul 29 '16 at 18:40
  • @Andre no, I'm not using VBA here at all. Unless exporting calls VBA or something? – Rominus Jul 29 '16 at 19:05
  • How do you export? Do you click a button on a form? What does that button have under the Events | Click property? Is it a macro or a VBA subroutine? – dbmitch Jul 29 '16 at 20:11
  • @dbmitch I'm exporting using the toolbar External Data tab – Rominus Jul 29 '16 at 20:38
  • Only unanswered questions: can more than one user use the db at one time? How often do you do a compact/repair? – dbmitch Jul 29 '16 at 21:00
  • @dbmitch there are no users except me at this time. Compact and repair hadn't been on my radar until today, but the database is only 4 weeks old, so that doesn't seem like a likely cause. – Rominus Jul 29 '16 at 21:23

1 Answers1

0

As a first step, it would be a good idea to save a backup copy and try "Compact & Repair."

With the database open, click File > Info > Compact & Repair.

See if this solves your issues.

Andrew L
  • 6,618
  • 3
  • 26
  • 30
  • 2
    For strange VBA-related errors, a complete decompile/compact/recompile might be better. See [this answer](http://stackoverflow.com/a/3268188/2144390) for details. – Gord Thompson Jul 29 '16 at 16:33