Results 1 to 3 of 3
  1. #1
    Join Date
    May 2009
    Posts
    3

    Unanswered: Runtime Error 3027: Cannot update. Database or Object is read-only.

    I'm trying to update a table and get the above error, I know the way I've opened is correct as I've open one above the same way, here is the code I have:

    sList = ""
    For I = 0 To (lstSelectedPosition.ListCount - 1)
    sList = sList & "'" & lstSelectedPosition.ItemData(x) & "',"
    Next I
    sList = Left(sList, Len(sList) - 1)
    strEmployeeQuery = "SELECT [Training History].[Employee ID], [Training History].Training, [Training History].[Date Completed], [Job History].Position FROM [Job History] INNER JOIN [Training History] ON [Job History].[Employee Number] = [Training History].[Employee ID] WHERE (([Training History].[Employee ID]=[Job History].[Employee Number]) AND ([Job History].Position IN (" & sList & ")));"

    Set dbEmployee = CurrentDb
    Set rstEmployee = dbEmployee.OpenRecordset(strEmployeeQuery)

    For I = 0 To (lstSelectedPosition.ListCount - 1)
    rstEmployee.AddNew
    rstEmployee![Training History].[Employee ID] = [Job History].[Employee Number]
    rstEmployee![Training History].[Training] = txtTraining
    rstEmployee.Update
    Next I

    rstEmployee.Close
    dbEmployee.Close
    Set rstEmployee = Nothing
    Set dbEmployee = Nothing


    Where is the issue causing the problem, I suspect it is in the WHERE statement as I ahve played with that a few times to get it to this point.

    I'm trying to Update table Training History (Three fields: Employee ID, Training, Date Complete (Blank to be entered later)) from the form. The form has a multi-select listbox holding positions and a textbox for the training name. Once it has the position from the listbox it uses Job History (fields: Employee Number and Position and other that link into other parts of the program, not my area) to match the position to any employee number that holds that position. I then use that number and add it to my table along with the training from the textbox.

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Take the content of your strEmployeeQuery after the Set command and see if you can make a query out of it and then edit the query. I think you'll quickly discover what is going on.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    May 2009
    Posts
    3
    Sorry it took so long to reply, this is a project I continue on days when I have time as things like this are not really part of my job.

    Ok you are right even though I actually created it in the query builder I never checked if I could edit it there. Any suggestions on another way to go about it? I have tried so many different ways to go about this.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •