Results 1 to 4 of 4
  1. #1
    Gina Maylone is offline Always learning
    Windows 10 Access 2016
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544

    Datebase or object suddenly read only

    Happy Friday!



    My working database has suddenly gone read only. I reverted to a back up that is not read only and run through the process of posting payments. It doesn't happen on the monthly process only on the "roads" process. Is there anything in my code that would make this happen? It breaks at the loop highlighted below.
    Code:
    Private Sub RoadsCheckNum_AfterUpdate()
        Dim dbs As DAO.Database
        Dim rst As DAO.Recordset
        Dim strsql As String
        Dim CN As String
        Dim BD As Variant
        Dim BL As Variant
        Dim CR As Currency
        Dim P As Currency
        Dim mbrid As Long
        Dim dp As Date
        Dim u As String
        Dim C As String
        
        '    Dim RC As Long
        'get values from sub form
        dp = Me.RoadsDatePaid
        u = Forms![memberpayments]![dbuser]
        CN = Forms![memberpayments]![RoadsPayments].Form![RoadsCheckNum]
        'debug.print u
        
        mbrid = Forms![memberpayments]![MemberID_PK]
        P = Me.Roadspayment
        BL = P  '<<-- payment amount
        'open recordset
        strsql = "SELECT roadsQueryforPayments.MemberID_FK, roadsQueryforPayments.DBAmount, roadsQueryforPayments.CRAmount,"
        strsql = strsql & " roadsQueryforPayments.dbdate, roadsQueryforPayments.AsmtType, roadsQueryforPayments.Details,"
        strsql = strsql & " roadsQueryforPayments.LotNumber, roadsQueryforPayments.EnteredBy, roadsQueryforPayments.crdate,"
        strsql = strsql & " roadsQueryforPayments.CheckNumber, roadsQueryforPayments.comments, [dbamount]-[cramount] AS baldue"
        strsql = strsql & " FROM roadsQueryforPayments"
        strsql = strsql & " WHERE roadsQueryforPayments.MemberID_FK = " & [Forms]![memberpayments]![MemberID_PK]
        'strsql = strsql & " And ([DBAmount] - [CRAmount]) > 0"
        
        strsql = strsql & " ORDER BY roadsQueryforPayments.dbdate;"
        Set rst = CurrentDb.OpenRecordset(strsql)
        'check for records in recordset
        If Not rst.BOF And Not rst.EOF Then
            rst.MoveLast
            rst.MoveFirst
            Do While Not rst.EOF
    
                'get values from each record in recordset
                BD = rst!baldue
                CR = rst!CRAmount
    
                'edit or add a payment to the record set
      
                If BL < BD Then   'less than
                    rst.Edit
                    rst!CRDATE = dp
                    rst!CRAmount = BL + CR
                    rst!CheckNumber = CN
                    rst!EnteredBy = Forms![memberpayments]![dbuser]
                    rst!Comments = dp & " - " & CN
                    rst.Update
                    BL = 0
                ElseIf BL > BD Then  'greater than
                    rst.Edit
                    rst!CRDATE = dp
                    rst!CRAmount = BD + CR
                    rst!CheckNumber = CN
                    rst!EnteredBy = Forms![memberpayments]![dbuser]
                    rst!Comments = dp & " - " & CN
                    rst.Update
                    BL = BL - BD
                ElseIf BL = BD Then  'equal to
                    rst.Edit
                    rst!CRDATE = dp
                    rst!CRAmount = BD + CR
                    rst!CheckNumber = CN
                    rst!EnteredBy = Forms![memberpayments]![dbuser]
                    rst!Comments = dp & " - " & CN
                    rst.Update
                    BL = 0
                End If
                rst.MoveNext
            Loop
    
            '---- extra left over after making payments ----
            'save remaining amt to additional principal in last records of record set
            If BL > 0 Then
                rst.MoveLast
                rst.Edit
                rst!CRAmount = rst!CRAmount + BL
                rst!Comments = dp & " - " & CN
                rst!EnteredBy = Forms![memberpayments]![dbuser]
                rst.Update
                BL = 0
            End If
    
            'add payment to payments table
            strsql = "INSERT INTO AsmtPayments ( MemberID_FK, [asmttype], PaymentAmount, PaymentDate, CheckNumber, enteredby )"
            strsql = strsql & " VALUES ( " & mbrid & ", '" & AsmtType & "'," & P & ", #" & dp & "#, '" & CN & "', '" & u & "');"
    
            
    DoCmd.OpenQuery "UpdateCRDATEStoNull"
        DoCmd.OpenQuery "balfwd"
        DoCmd.OpenQuery "cleanupoverpayments"
        Forms![memberpayments]![AsmtPayments].Form.Requery
    Forms![memberpayments]![AsmtPayments].Form.Refresh
        Me.Refresh
    CurrentDb.Execute strsql, dbFailOnError
        End If
    
        rst.Close
        Set rst = Nothing
        
        
        Forms![memberpayments]![AsmtPayments].Form.Requery
        
        'MsgBox "End of process"
    End Sub
    Thanks in advance for any thoughts!!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Do you know if the If or ElseIf ran and successfully edited the recordset? It would be pretty odd if they worked and the bit in red didn't. Is roadsQueryforPayments editable if you open it directly?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Gina Maylone is offline Always learning
    Windows 10 Access 2016
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    Hi Paul! I checked the query which was not updateable because i had it set to distinct (no duplicate values) so I changed that and was able to enter a record. And now, no lock issues! Thank you!!!!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Glad you got it sorted!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 6
    Last Post: 07-09-2015, 06:40 PM
  2. Replies: 8
    Last Post: 11-09-2014, 03:18 PM
  3. Cannot update. Database or object is read-only ERROR
    By Namibia in forum Import/Export Data
    Replies: 2
    Last Post: 06-05-2012, 05:32 PM
  4. Can Not Update. Object is Read Only
    By mrfixit1170 in forum Programming
    Replies: 3
    Last Post: 01-03-2012, 03:35 PM
  5. form is suddenly read-only
    By Karen H in forum Forms
    Replies: 28
    Last Post: 02-14-2011, 08:38 AM

Tags for this Thread

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