Results 1 to 13 of 13
  1. #1
    N7925Y is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Apr 2016
    Posts
    32

    Error when linking subform to form


    I have a form with two subforms:


    frmNameMain

    frmPhoneNumberSub

    frmPhoneContactSub


    My ultimate goal is to link the two subforms together. Unfortunatley I havent found a way to do that. So I have added a unbound text box to the main form and set the record source back to the subform field. I will then link the other subform to the main form to pull that data in. However, when i do this i get an error message "You can't assign a value to this object."

    I have attached a sample database so you can see the error for yourself. If you open the frmNamemain and try to add a phone number you get the error. It seems to only occur when you initial open the form and add the number. After you get the error and try to add another number you don't get the error. Any thoughts? I figure I have something programed wrong.

    PhoneNumberSampleDatabase1.zip

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    the master form has a master.ID field
    both subforms also have a master.ID field.
    in both subform properties, set the LINK MASTER FIELDS, and LINK CHILD FIELDS, to ID

    They then sync.

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I don't really understand what you are trying to do, but you can't do what you want to do like you are trying to do.

    You would have to have "frmNameMain" with a sub form "frmPhoneContactSub" that has a subform (a sub-sub-form) "frmPhoneNumberSub".
    (also look at the relationship window)


    Something like this???? (I am confused )
    Attached Files Attached Files

  4. #4
    N7925Y is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Apr 2016
    Posts
    32
    I have both the Master and Child fields linked to the txtPhoneNumber_ID. So they are syncing, because the Number ID does show up in the main form. But I still get the error

  5. #5
    N7925Y is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Apr 2016
    Posts
    32
    What i am trying to do is carry the Phone Number ID over from the subform-phone number to the subform-phone contact. What you have done would work great if I could get it to do it. I've opened you sample database and when i add a new phone number, the phone number ID does not populate the other subform. Any ideas on how to make that work?

  6. #6
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    because the Number ID does show up in the main form
    It is pointing to the field on the subform. You are linking a subform to itself.

  7. #7
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    This doesn't make sense to me... but then again, I banged my head a few months ago and many things do not make sense....

    Maybe this????
    Attached Files Attached Files

  8. #8
    N7925Y is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Apr 2016
    Posts
    32
    We are almost there!!! you've got the Phone Number ID working but the Contact ID needs to be in the other sub form "PhoneContact".

  9. #9
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    the Contact ID needs to be in the other sub form "PhoneContact".
    No it doesn't!

    The main form "frmNameMain" is linking to "frmPhoneNumberSub" & "frmPhoneNumberSub" is linking to "frmPhoneContactSub".


    A normal design would be:
    main form ----------->> sub form ---------->> sub sub form
    "frmNameMain" -->>"frmPhoneNumberSub"---->> "frmPhoneContactSub"


    But you have a main form and two subforms at the same level with one sub form linking to the other sub form. (the same as described above)


    You can add the Contact ID field to the form "frmPhoneContactSub", but it accomplishes nothing. If you try to link "frmPhoneContactSub.ContactID_FK" to the main form "frmNameMain.ContactID_PK", I think it will form a circular link and quit working.


    I'm sorry... the names don't make sense to me. I had to add suffixs "_PK" and "_FK" to keep track of the linking fields. I added a field to one table just to have something to enter in the table other than PK & FK fields.

    I don't know how I can help any more.....
    Good luck...

  10. #10
    N7925Y is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Apr 2016
    Posts
    32
    "ssanfu"

    I really appreciate all your help with trying to figure my issue out. You made me realize that i needed to restructure my tables and the forms would work. Your "database2" is the correct way to do it and that is the setup i am going to use. I'm trying to use the sample database you have created but I can't get the PhoneType_ID_PK in the frmPhoneContactSub to update with the new phone ID from the frmPhoneNumberSub form. Thoughts?

  11. #11
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I'm trying to use the sample database you have created but I can't get the PhoneType_ID_PK in the frmPhoneContactSub to update with the new phone ID from the frmPhoneNumberSub form
    Which sample dB? "PhoneNumberSampleDatabase2.accdb"?

  12. #12
    N7925Y is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Apr 2016
    Posts
    32
    Yes, "PhoneNumberSampleDatabase2.accdb"

  13. #13
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Interesting....... All of the PK/FK fields are linked when a new record is entered in my copy of the dB.


    Look at this dB........
    Attached Files Attached Files

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

Similar Threads

  1. Replies: 14
    Last Post: 12-01-2015, 02:55 PM
  2. Replies: 2
    Last Post: 04-20-2013, 03:37 AM
  3. Replies: 15
    Last Post: 03-05-2013, 11:57 PM
  4. Form - subform linking problem
    By Justin in forum Access
    Replies: 1
    Last Post: 11-11-2010, 11:21 AM
  5. Linking Subform Control to Main form
    By KWarzala in forum Forms
    Replies: 1
    Last Post: 03-13-2010, 08: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