Results 1 to 7 of 7
  1. #1
    excellenthelp is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Mar 2014
    Posts
    93

    Error: "Cannot update. Databse or Object is read-only" Issue

    Hello Accessers,

    I am attempting to find the flaw in the code below after an error pops up: "Run-time error '3207': Cannot update. Database or object is read-only." At the beginning of debugging process, I am being led to RS.Edit where it is highlighted.

    Any ideas?



    Code:
    Public Function FlawCode()    Dim i As Long
        
          With Screen.ActiveForm.[FieldABC]
          
                Dim stNextUser As String
                Dim MyDB As Database, RS As Recordset
                Set MyDB = DBEngine.Workspaces(0).Databases(0)
                
                stNextUser = ""
            
                Set RS = MyDB.OpenRecordset("select * from qryName_Type")
                lngRSCount = RS.RecordCount
                If lngRSCount <> 0 Then
                    RS.MoveFirst
                    
                    stNextUser = Trim(RS.Fields("ABC").Value)
                    
                    RS.Edit
                    RS.Fields("DateABC").Value = Now()
                    RS.Update
                    RS.Close
                    MyDB.Close
                   
                Else
                    RS.Close
                    stMsg = MsgBox("An error has occured", vbCritical)
                    MyDB.Close
                End If
        
          DoCmd.GoToRecord , , acNewRec
        
            For i = 0 To .ListCount
                If .ItemData(i) = stNextUser Then
                    .Value = stNextUser
                    MsgBox "Hi", vbApplicationModal
                End If
            Next i
        End With
    End Function

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    I dont think you should be using this code for update...This can be accomplished without code and a single update query.

    What is it doing here?

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Please show the code for
    qryName_Type

    and I agree What is the code suppose to do?

  4. #4
    excellenthelp is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Mar 2014
    Posts
    93
    This is to automatically assign new task to an employee with the oldest date last assigned.

    I will work on it since the same code works just fine on the original database- it does not work when I tried to copy the same code to the newer database.

    Thanks though!

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Quote Originally Posted by excellenthelp View Post

    ...the same code works just fine on the original database- it does not work when I tried to copy the same code to the newer database...
    This statement, and the error code given, would suggest that qryName_Type is a Read-Only Query, while the Query in the original database probably wasn't Read-Only Query.

    As orange suggested, we need to see the SQL for the Query.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    Cheryl Lodge is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    May 2022
    Posts
    1
    Hello,

    Try the below mentioned solutions, and check if any of them can work for you:

    Solution 1: Right mouse click on the file itself and see if it's Read Only. This code happen if copied from another location of downloaded from email.

    Solution 2:If that does not work, make a back-up, then make sure *Track name AutoCorrect info* is unchecked, run a Compact & Repair and see if that works.


    Solution 3:Still not working? Make a back-up again and then create a new database front end. Uncheck *Track name AutoCorrect info* and *Compact on Close* and import all your Objects in. Hopefully, this resolves the issue.

    Best Regards,
    Cheryl


  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    Just resurrected an 8 year old thread?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

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

Similar Threads

  1. Replies: 14
    Last Post: 08-19-2013, 09:37 AM
  2. I can't do "This"? (Object issue)
    By GraeagleBill in forum Programming
    Replies: 1
    Last Post: 07-21-2013, 07:34 PM
  3. Exporting to .dbf "can't find object" error
    By fedyazar in forum Import/Export Data
    Replies: 6
    Last Post: 03-27-2013, 02:41 PM
  4. Replies: 1
    Last Post: 03-14-2013, 12:39 PM
  5. Replies: 1
    Last Post: 04-14-2011, 03:46 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