Results 1 to 6 of 6
  1. #1
    MichaelA is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Location
    Wisconsin
    Posts
    139

    Cannot Close Form or Navigate to Other Records

    I have a Form Books which is set to open to a New Record. When I try to navigate away from the New Record either by closing the form or by going to a previous or next record, I get the following (You cannot add or change a record because a related record is required in table "Authors.") I have not tried to make any changes to the new record on any fields, only opened it and then tried to navigate away.



    Thank you in advance for your help.

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,816
    My guess is that one or more controls on that form have a default value set. When you're in a new record mode, you've started one if there are defaults (I believe that is true even if the defaults are at the table field level) and it seems that the record is a child of some other related table. The message is telling you that parent table has no record related to the one you're likely unintentionally starting.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    MichaelA is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Location
    Wisconsin
    Posts
    139
    OK, so I found the problem it is coming from this code:

    Private Sub chkLoaned_AfterUpdate()
    Me.txtLoanedTo.Visible = Me.chkLoaned
    Me.txtDateOut.Visible = Me.chkLoaned
    If Me.chkLoaned = True Then
    Me.txtDateOut = Date
    Else: Me.chkLoaned = False
    Me.txtDateOut = ""
    End If
    End Sub


    Private Sub Form_Current()
    Me.txtLoanedTo.Visible = Me.chkLoaned
    Me.txtDateOut.Visible = Me.chkLoaned
    If Me.chkLoaned = True Then
    Me.txtDateOut = Date
    Else: Me.chkLoaned = False
    Me.txtDateOut = ""
    End If
    End Sub

    This is in the form to make two text boxes invisible unless a checkbox is checked. It also inserts the current date into one of the textboxes. Is there a way, short of eliminating this feature, from preventing this error?

    Thank you for your help!

  4. #4
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,655
    It also inserts the current date into one of the textboxes.
    By setting a value in code you are dirtying the form which causes what Micron described.

    Code:
    If Me.chkLoaned = True Then
    Me.txtDateOut = Date
    Else: Me.chkLoaned = False
    Me.txtDateOut = ""
    End If

  5. #5
    MichaelA is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Location
    Wisconsin
    Posts
    139
    Is there a way around this?

  6. #6
    MichaelA is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Location
    Wisconsin
    Posts
    139
    I think I figured it out. I just deleted:

    Thank you!

    Else: Me.chkLoaned = False
    Me.txtDateOut = ""



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

Similar Threads

  1. Navigate Subform Records by Main ID
    By Ramtrap in forum Forms
    Replies: 3
    Last Post: 10-11-2017, 01:18 PM
  2. Replies: 1
    Last Post: 12-11-2013, 11:03 AM
  3. navigate records on the form is slow
    By masoud_sedighy in forum Forms
    Replies: 3
    Last Post: 09-28-2013, 01:32 PM
  4. Replies: 9
    Last Post: 08-07-2012, 11:50 AM
  5. Buttons on form to navigate through records
    By emilyrogers in forum Forms
    Replies: 2
    Last Post: 07-19-2011, 10:17 AM

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