Results 1 to 3 of 3
  1. #1
    MikeN is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2015
    Posts
    39

    Related record error on dialog form

    I am working on a database that users can use to input field collection data for an undergraduate course but keep running into a "related record is required..." problem in an associated dialog form.

    The main form (frm_Trip) has data fields that get filled out, then the user clicks a button to open up the survey form (frm_BeltSurvey) which has the user-defined fields "cmbtransect" and "txtObservers," and a subform (frm_BeltSurveySub) that allows the user to select a species and count based on their survey observations. The error I keep getting is "You cannot add or change a record because a related record is required in table "tbl_Trip." This error doesn't occur if I add a record into tbl_Trip (through frm_Trip), close the form, open it back up, manually select the 'old' record, and then continue through the button click to the frm_BeltSurvey. So, I presume it isn't saving the record in frm_Trip before opening the dialog form, frm_BeltSurvey? Any suggestions? Ultimately there will be multiple buttons for different survey types but I'm just working on the Belt Survey first...the rest should easily follow suit once I get the design set for the one.

    In case this might influence your suggestion, the 'on click' code used to link frm_Trip and frm_BeltSurvey is:
    'Open Belt Survey form linked to Trip
    DoCmd.OpenForm "frm_BeltSurvey", _


    DataMode:=acFormAdd, _
    WindowMode:=acDialog, _
    OpenArgs:=(Me.TripID)

    I've attached an image of where the code is showing up to accompany my explanation of the steps.
    Attachment 22700

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Maybe commit the record to table before opening dialog form. Options:

    If Me.Dirty Then Me.Dirty = False

    or

    If Me.NewRecord Then DoCmd.RunCmd acCmdSaveRecord
    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
    MikeN is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2015
    Posts
    39
    Thanks June! Me.Dirty worked!

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

Similar Threads

  1. Replies: 15
    Last Post: 03-05-2015, 03:30 PM
  2. Table Relationships w/ Related Record error
    By Dave D in forum Database Design
    Replies: 17
    Last Post: 07-16-2014, 12:50 PM
  3. Replies: 7
    Last Post: 07-02-2012, 10:50 PM
  4. Replies: 8
    Last Post: 10-27-2011, 02:11 PM
  5. Replies: 12
    Last Post: 09-09-2011, 11:14 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