Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Field cannot be updated (MSACCESS2003)

    i am getting an error 3164 saying a field cannot be updated. The fieldname is Location. Can someone see why. Thanks

    ' SQL for log table
    SQL = "SELECT LogsA.Athlete, LogsB.Location FROM LogsA INNER JOIN LogsB ON LogsA.IDD = LogsB.IDD;"
    Set rst = db.OpenRecordset(SQL, dbOpenDynaset)

    ' SQL for main documents
    SQL2 = "SELECT * FROM MainDirDocs;"
    Set rst2 = db.OpenRecordset(SQL2, dbOpenDynaset)

    Do While Not rst2.EOF

    If rst2("Done") = 1 Then ' Add name to log table

    rst.AddNew
    rst("Athlete") = rst2("Athlete")
    rst("Location") = rst2("SD1DOC")
    rst.Update
    End If

    rst2.MoveNext
    Loop

  2. #2
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Field cannot be updated (MSACCESS2003)

    I have managed to get the code to work by splitting the two joined tables and dealing with the first table and then dealing with the second one, putting in the foreign key. Is there a way to add new records to a joined/related table in one shot or do they have to be broken up? Thanks

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Field cannot be updated (MSACCESS2003)

    The recordset rst is based on two tables. You're trying to create a new record in both tables at once, that is not possible.

  4. #4
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Field cannot be updated (MSACCESS2003)

    Many thanks Hans for confirmation. Regards

Posting Permissions

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