Results 1 to 6 of 6
  1. #1
    jerem is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    88

    Form and Subform with same record source

    Hi
    I created a form and a subform with the same record source. The reason for that is that I have a tab in a tab, and the only way to get that to work is to create a subform. So my Form has an ID field and mu Subform also has an ID field, which essentially is the same field. Now if I try to save the changes that I make in this form and subform, I get the duplicate value error.
    Any idea how I could address this?
    Thanks.



    Cross:
    http://www.utteraccess.com/forum/For...-t2022829.html
    http://www.access-programmers.co.uk/...59#post1388659

  2. #2
    jerem is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    88
    Ok... To get it to work, I changed the Master-Child link: Now, Link Child Field is the field ID and Link Master Field is the control txtID. No duplicate value issue anymore, however now it creates an extra empty record when using the form to add data. Should I get rid of it manually or is there something I am not doing right?

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by jerem View Post

    ...To get it to work...

    ...however now it creates an extra empty record when using the form to add data...
    But you haven't gotten it to work, have you? And long story made short, you're not going to be able to, as presently configured! This question comes up often enough that I have a boilerplate answer archived:

    A Form/Subform from the same Record Source will mean that one of the Forms will not be editable, since you have the same Record open twice, in different Forms.

    If you get into Editing the Records, you'll also start having Write Conflicts, always a hairball to sort out!

    When you create a New Record in the Subform, the Field named in the Subform Control's LinkChildFields Property normally inherits its Value from the Field named in LinkMasterFields. Typically, Access will assign the Primary Key field to these Properties. If the Record on the Main Form is not a New Record, the Subform will try to use the same Primary Key Value as the Record in the Main Form, and since they are both using the same Table, you'll get the


    The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship

    Error Message that necessitated this thread in the first place!

    Perhaps a better approach would be to look at why you need a Tabbed Control within a Tabbed Control.

    Linq ;0)>

  4. #4
    jerem is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    88
    The reason I need it is that structuring the form this way looks good and works well with the amount of data. What would the alternative be to avoid having a tab in another tab?

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I also don't understand why you need a tab within a tab. Why not just distribute the fields over multiple tabs of one tab control?
    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.

  6. #6
    jerem is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    88
    Then I'd have too many tabs and it doesn't look good anymore. Another thing I could do is split the data into two tables. Although I'm afraid this is prioritising style over performance.

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

Similar Threads

  1. Replies: 6
    Last Post: 08-21-2013, 02:51 PM
  2. Replies: 6
    Last Post: 08-22-2012, 03:24 AM
  3. Replies: 14
    Last Post: 05-25-2012, 02:40 AM
  4. Replies: 6
    Last Post: 05-05-2012, 08:43 AM
  5. Replies: 16
    Last Post: 01-16-2012, 09:43 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