Results 1 to 9 of 9
  1. #1
    pelizdr is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    4

    MS Access 2016 Table read-only, unable to update from scheduled macro?

    New user to forum, I have an odd issue with a macro stopping due to a table being "read only" (macro kicks off a bunch of VBA scripts to update various tables and massage data). The database and macro have not changed in a number of months, the only change I can think of is MS updates for Office 2016. I generally call the macro using a scheduled task. When the macro gets to the point of importing data into a local table, the macro stops and says unable to import data due to the table being read only. If I run the same macro after opening the database myself (and taking my time to scroll down and launch the macro), it runs just fine. I tried to add a simple counting loop to see if this was some kind of odd timing issue, but adding two seconds before the query doesn't seem to help.



    Wondering if anyone else has experienced this, and how they got around it. I would much rather NOT wake up at 3:00 am to run this process lol.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    is this a single all-in-1 database with no other users?
    or
    a split database where others can use?

    are there any open forms when the macro runs?

  3. #3
    pelizdr is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    4
    there are no other users, this database is a back end to update MS SQL tables, the only form that is open is the switchboard on open, users access the data from a completely different front end. This process has been chugging along for awhile, just recently (like within the last week or so) has had issues running the VBA to import data into a local table (the table is located in Access, not SQL).

  4. #4
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Windows 10 - a REALLY bad operating system. MS screws things up on a daily basis.

  5. #5
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Newer versions of Access are less forgiving of code errors than older versions but generally that's a good thing.

    Does your SQL table have a PK field?
    Does it have any Boolean fields where you haven't set a default value?
    Can it be edited in SQL server?
    Can it be edited manually in Access?
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  6. #6
    pelizdr is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    4
    Quote Originally Posted by ridders52 View Post
    Newer versions of Access are less forgiving of code errors than older versions but generally that's a good thing. - I don't believe this is a code error, the update query begins to run and tells me the table is read-only

    Does your SQL table have a PK field? - this is not an SQL table, this is a local Access table, but yes, the table does have a PK
    Does it have any Boolean fields where you haven't set a default value? no
    Can it be edited in SQL server? - N/A this is a local Access table, not an SQL table
    Can it be edited manually in Access?
    I responded to your comments, the issue I don't believe is code, I can open the database manually and kick off the exact same macro that launches the VBA code without issue, when I kick off the macro from command line/task scheduler, it tells me the local table is read only. I didn't even know you could set Access tables to be read-only. What I think may be happening is the database isn't opening "enough" on launch before the macro kicks off.

  7. #7
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Not sure why that would make it read only ,,,,

    Anyway, try & test that by running something else first
    OR use the sleep API function to make the database wait for a couple of seconds then run your code

    Paste this line in the declarations section of a standard module:
    Code:
    Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
    The causes a delay of the specified number of milliseconds

    Usage example - causes 2 second delay
    Code:
    Sleep 2000
    Suggest you put that in a function along with your other code
    Then run that function using an autoexec macro at startup
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  8. #8
    pelizdr is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    4
    So, this is humorous, and only MS people would get this. I changed nothing, and the process ran fine this morning. Instead of building a module (as simple as that one is), I had stuffed this in a couple weeks ago.
    Code:
    Twait = Time
    Twait = DateAdd("s", 30, Twait)
    Do Until Tnow >= Twait
    Tnow = Time
    Loop

  9. #9
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977

    Or just use
    Code:
    Sleep=30000
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Unable to remove password from Access 2016
    By RichardJK in forum Access
    Replies: 6
    Last Post: 11-22-2020, 01:00 PM
  2. unable to create Access 2016 blank database -
    By imtahmad2001 in forum Access
    Replies: 2
    Last Post: 07-08-2016, 03:57 PM
  3. Replies: 1
    Last Post: 01-21-2016, 05:26 PM
  4. Form to update a table without read access
    By macroRoniAndCheese in forum Forms
    Replies: 2
    Last Post: 03-01-2013, 02:58 PM
  5. Unable to Read from COM ports in Access 2003
    By userThree in forum Programming
    Replies: 3
    Last Post: 07-31-2011, 08:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums