Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    stewegg is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2017
    Posts
    26

    Change records inside continuous form Runtime Error '3164': field cannot be updated

    I got a continuous form with multiple fields.
    The field control source are directly from each tables.


    Right now, I got a button click action that would apply the different info to the specific fields.
    However, the evil Runtime Error '3164': field cannot be updated came up.....
    Can't figure out why.....Help! Please!

    Thank you very much!

    Code:
        With Me.RecordsetClone
            .MoveFirst
        Do While .EOF = False
            .Edit
            .Fields("Status").Value = "Home"
            .Fields("LocationNumber").Value = 1 '(1 being at home)
            .Fields("Active").Value = 0 '(this is a true/false field)
            .Fields("ActionDate").Value = Date
            .Update
            .MoveNext
        Loop
        End With
    Error @ .Fields("LocationNumber").Value = 1 '(1 being at home)


  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    Don't know enough about data structure to advise.

    Why do you need code to enter data?

    If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    stewegg is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2017
    Posts
    26
    This code is for a button at the footer of a continuous form.
    When user click the button, it suppose to change the Status, LocationNumber, Active and ActionDate of all the records in the continuous form.

    I tested the recordset using codes below without any issue.
    msgbox gives me the correct information.
    It's when I tired to change the fields it starts giving me errors
    Code:
    For i = 0 To 3
        With Me.RecordsetClone
            .MoveFirst
        Do While .EOF = False
            .Edit
            Select Case i
            Case 0
                test=.Fields("Status").Value
                MsgBox test
            Case 1
                test2=.Fields("LocationNumber").Value
                MsgBox test2
            Case 2
                 test3=.Fields("Active").Value
                MsgBox test3
            Case 3
                 test4=.Fields("ActionDate").Value
                MsgBox test4
             End Select
            .Update
            .MoveNext
        Loop
        End With
    Next i

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    That still doesn't help analyze issue. No idea why VBA rejects that field reference. If you can't or won't provide file, doubt I can help.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    stewegg is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2017
    Posts
    26
    Don't know if this helps but LocationNumber field is in a different table than Status. :|

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    There you are. A form should do data entry/edit for only 1 table. So why is this field in this form RecordSource and why should it be changed? How are tables related?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    stewegg is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2017
    Posts
    26
    Would putting the tables in one query solve the problem?

    The two tables are related by having one referring to another's unique ID.
    Table #1 contains:
    Field: Status
    Field: Table2ID

    Table #2 contains:
    Field: LocationNumber
    Field: Active
    Field: ActionDate

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    Not sure because I am not understanding data relationship.

    Can a Table#2 record have multiple Table#1 status records associated? If not, why have a separate table?

    The form design makes no sense with that data structure.

    Are those actual table names? Poor naming convention if it is.

    Again, this would probably go a lot faster if you provided db.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    stewegg is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2017
    Posts
    26
    I totally understand it's hard to work on things that you can't see.
    However, due to confidential information, I can't really provide with you the database.
    I am really sorry about that.

    The records in Table #1 can have multiple Table #2 Locations records.
    To make it easier to understand, table #1 contain the list of people with their current status (home, warehouse, office, vacation...etc)
    Table #2 contain the history of their location/station (locationNumber, Active location or not, ActionDate (the date this person is change out of this location/station)

    I hope this helps.

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    You could make a copy and remove confidential info.

    You don't show people info fields for Table1. Seems to me the relationship is backwards. Table1 ID should be saved into Table2.

    Should use form/subform arrangement.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    stewegg is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2017
    Posts
    26
    I have taken out most of stuff in the database.
    The button I am working on is the "Send All Home" in the footer of the form.
    B/c it's larger than 500KB, I have uploaded to google drive in the link below:
    https://drive.google.com/file/d/1b0x...ew?usp=sharing

    Thank you very much

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    A form should do data entry/edit for only 1 table. Which table should this form edit - tblProject?

    LocationID is autonumber field in tblLocation so of course cannot edit that field. If you want to change LocationID in tblDeployment, that will require a separate action. Cannot edit that field through this form RecordSource.

    Next time Zip the file and attach to post. Zip of 2MB allowed.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    stewegg is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2017
    Posts
    26
    Status is in tblEquipment
    Active in tblDeployment
    RemovalDate in tblDeployment

    It's not changing the autonumber field LocationID in tblLocation, it should sending the selected equipment to LocationID=1 (which is default Home).

  14. #14
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    Your code is attempting to change value of LocationID in tblLocation because that is the field in the form's RecordSource. So fix that and I retract my earlier statement. You will be able to edit LocationID from tblDeployment.

    This confusion is common when using same field name in multiple tables.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #15
    stewegg is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2017
    Posts
    26
    How do I fix that issue?
    Why does the "Send Home" button works fine but "Send All Home" does not work?

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to change date format inside a text field?
    By johnrohan in forum Access
    Replies: 3
    Last Post: 08-21-2017, 12:59 PM
  2. Runt time error 3164 field can not be updated
    By sprtrmp in forum Programming
    Replies: 12
    Last Post: 10-27-2015, 07:06 AM
  3. Replies: 3
    Last Post: 05-27-2015, 08:35 AM
  4. Replies: 6
    Last Post: 07-24-2014, 08:18 AM
  5. Error # 3164 "field cannot be updated"
    By bbrazeau in forum Access
    Replies: 3
    Last Post: 08-29-2013, 01:18 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