Results 1 to 5 of 5
  1. #1
    wily_wolf is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Feb 2016
    Posts
    36

    Run-Time Error 3027: Can't update. Database or object is read-only

    Hello again,



    I published another database to SharePoint (blah) and after altering my tables to make them "web compatible" everything seemed to have moved over and published just fine. However, when users (including myself) access the database, they are able to get into the form used to input time for certain projects. So, I'm thinking, "Great!" But, upon hitting the Submit button to enter their records, the error message "Run-Time Error 3027: Can't Update. Database or object is read-only" pops up. When I select Debug, it points me to the RunSQL statement within my VBA. Here is the entire code below w/ the error in red:
    ---------------------------------------------------------------------------
    Private Sub cmdApply_Click()
    Call setGlobals

    If IsNull(gAlias) Then
    gAlias = Environ("Username")
    Call setAccess(gAlias)
    End If

    If IsNull(Me.cboBucket) Then
    MsgBox "Please select a Category.", vbOKOnly, "Bucket Required"
    Me.cboBucket.SetFocus
    Me.cboBucket.Dropdown
    Exit Sub
    End If

    If IsNull(Me.ProjectDate) Then
    MsgBox "Please select a Date.", vbOKOnly, "Date Required"
    Exit Sub
    End If

    If IsNull(Me.ProjectHours) Then
    MsgBox "Please enter amount of hours (including 0).", vbOKOnly, "Enter Hours"
    Exit Sub
    End If

    If IsNull(Me.ProjectMins) Then
    MsgBox "Please enter the minutes spent on the project.", vbOKOnly, "Enter Minutes"
    Exit Sub
    End If

    If (Me.ProjectHours = 0) And (Me.ProjectMins = 0) Then
    MsgBox "Please enter time spent on the category.", vbOKOnly, "Enter Time"
    Exit Sub
    End If

    Dim strSQL As String
    Dim strMsg As String
    Dim intCount As Integer
    Dim selDate As Date

    selDate = CDate(Month(Me.ProjectDate) & "/1/" & Year(Me.ProjectDate))
    strSQL = "INSERT INTO tblTimeTracker (Alias, BucketID, ProjectDate, ProjectHours, ProjectMins)" & _
    "VALUES ('" & gAlias & "', " & Me.cboBucket.Column(0) & ", #" & Me.ProjectDate.value & "#, " & Me.ProjectHours & ", " & Me.ProjectMins & " )"
    strMsg = "Hours entered for " & Me.cboBucket.Column(1)

    DoCmd.SetWarnings False
    DoCmd.RunSQL strSQL
    DoCmd.SetWarnings True
    MsgBox strMsg, vbOKOnly, "Entry Successful"
    Call setDates
    Call crosstabRequery
    End Sub
    -----------------------------------------------------------------------------

    I've searched the error code and there were suggestions like, copy my stuff into a new database and delete the old one, use compact and repair, etc... really nothing to do with the VBA. So, with that said, is there anything that I could maybe do with my VBA to save this or is it something with the database as a whole?

    Any help would be much appreciated. Thanks.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    I am not familiar with Sharepoint. I'd suggest that you put a debug.print strSQL before your docmd.setwarnings false
    to see what is really in the rendered SQL.

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    strSQL = "INSERT INTO tblTimeTracker (Alias, BucketID, ProjectDate, ProjectHours, ProjectMins)" & _
    "VALUES ('" & gAlias & "', " & Me.cboBucket.Column(0) & ", #" & Me.ProjectDate.value & "#, " & Me.ProjectHours & ", " & Me.ProjectMins & " )"
    The above has no space " " before the "VALUES... clause. Orange's suggestion would have shown that.

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    I'm not very familiar with sharepoint either, but given the error message you are getting, you might want to check that the permissions you and the other users have on the sharepoint site are sufficient to allow you to make updates to the database.

  5. #5
    wily_wolf is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Feb 2016
    Posts
    36
    Thank you for your responses. SharePoint was continuing to have problems with the SQL statement so I replaced the statement with a OpenRecordset method and went from there. Everything seems to be working as intended.


    Private Sub cmdApply_Click()

    Call setGlobals

    If IsNull(gAlias) Then
    gAlias = Environ("Username")
    Call setAccess(gAlias)
    End If

    If IsNull(Me.cboBucket) Then
    MsgBox "Please select a Category.", vbOKOnly, "Bucket Required"
    Me.cboBucket.SetFocus
    Me.cboBucket.Dropdown
    Exit Sub
    End If

    If IsNull(Me.ProjectDate) Then
    MsgBox "Please select a Date.", vbOKOnly, "Date Required"
    Exit Sub
    End If

    If IsNull(Me.ProjectHours) Then
    MsgBox "Please enter amount of hours (including 0).", vbOKOnly, "Enter Hours"
    Exit Sub
    End If

    If IsNull(Me.ProjectMins) Then
    MsgBox "Please enter the minutes spent on the project.", vbOKOnly, "Enter Minutes"
    Exit Sub
    End If

    If (Me.ProjectHours = 0) And (Me.ProjectMins = 0) Then
    MsgBox "Please enter time spent on the category.", vbOKOnly, "Enter Time"
    Exit Sub
    End If

    Dim rst As DAO.Recordset
    ' Dim strSQL As String

    Dim strMsg As String

    Dim intCount As Integer
    Dim selDate As Date
    selDate = CDate(Month(Me.ProjectDate) & "/1/" & Year(Me.ProjectDate))

    Set rst = CurrentDb.OpenRecordset("tblTimeTracker")

    rst.AddNew
    rst![Alias] = gAlias
    rst![BucketID] = Me.cboBucket.Column(0)
    rst![ProjectDate] = Me.ProjectDate.Value
    rst![ProjectHours] = Me.ProjectHours.Value
    rst![ProjectMins] = Me.ProjectMins.Value

    rst.Update

    rst.Close
    Set rst = Nothing

    ' strSQL = "INSERT INTO tblTimeTracker (Alias, BucketID, ProjectDate, ProjectHours, ProjectMins)" & _
    '"VALUES ('" & gAlias & "', " & Me.cboBucket.Column(0) & ", #" & Me.ProjectDate.Value & "#, " & Me.ProjectHours & ", " & Me.ProjectMins & " )"

    strMsg = "Hours entered for " & Me.cboBucket.Column(1)

    DoCmd.SetWarnings False
    ' DoCmd.RunSQL strSQL
    DoCmd.SetWarnings True

    MsgBox strMsg, vbOKOnly, "Entry Successful"

    Call setDates
    Call crosstabRequery

    End Sub



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

Similar Threads

  1. Replies: 3
    Last Post: 07-20-2015, 12:23 PM
  2. Replies: 2
    Last Post: 12-19-2014, 07:41 AM
  3. Replies: 2
    Last Post: 11-18-2014, 08:56 AM
  4. 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
  5. Runtime Error '3027': Database or object is read only
    By 4x4Masters in forum Programming
    Replies: 4
    Last Post: 06-08-2010, 08:02 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