Results 1 to 5 of 5
  1. #1
    Dal is offline Novice
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    27

    Previously 'Required' Fields Still Require Values To Create A New Record


    I changed the fields in the relating table to no longer be required. Despite this when initializing a new record in the consecutive form I receive a run-time error '3201 You cannot add or change a record because a related record is required...'. This is untrue, the fields are not set to required. There are relationships; one-to-many; with the many side being where the record is being created but I cannot see how this changes things; relationships do not require population of corresponding fields.

    There are events relating to two of the three fields but these events are not fired. What could be causing this? As for the third field (relating to a separate table completely) with no events whatsoever this proves this is not the issue. It is as if the db engine has not updated. A combobox inellisence reference failed to update the other day after renaming it; it kept appearing as it's old name.

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Yes, they do. You need a parent for a child record. That is what the error message is telling you. Nothing to do with a required field for a record
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    relationships do not require population of corresponding fields.
    All depends if you are enforcing referential integrity - if you are then it is required, if not then you are not really setting a relationship, just a 'join template'.

    There is a way you can enforce referential integrity and enter child records without a parent, and that is to set the FK default to null - usually that is the default value when creating a text or number field. If you want to ensure a child record cannot be created without a parent, set the default to 0, -1 or some other value that will never be a valid FK value (and don't allow the situation where a user can change the value to null) - or just set the required property to true

    One other tip, if you have a system where you will have numerous null values for a FK, modify the index to ignore nulls - index will be smaller and consequently faster but probably not that noticeable on a few 100k of records

  4. #4
    Dal is offline Novice
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    27
    Quote Originally Posted by CJ_London View Post
    you can enforce referential integrity and enter child records without a parent, and that is to set the FK default to null
    High calibre input; thank you. I'm using RI everywhere. I thought i read a Microsoft article stating populated fields were not required & it seemed quite simplistic for it not to be possible.

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    I use that method for cash accounting (which does not use accruals and prepayments) - any entry with a null fk is a simple way to identify pending cash movements

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

Similar Threads

  1. Replies: 3
    Last Post: 07-07-2020, 10:35 AM
  2. Replies: 7
    Last Post: 08-14-2018, 11:32 AM
  3. Replies: 4
    Last Post: 08-30-2017, 06:40 AM
  4. Additional Value List edits erasing previously entered fields
    By rshepard@shepardsearch in forum SharePoint
    Replies: 2
    Last Post: 06-27-2017, 07:19 AM
  5. Replies: 12
    Last Post: 10-03-2013, 12:32 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