Results 1 to 14 of 14
  1. #1
    goodguy is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Location
    Zanzibar, Tanzania
    Posts
    229

    Cascading tables on one form

    In my db, I have a chain of 5 tables (1-Many relationship ) with cascading foreign keys on each table on the many side. Due to normalization, Table3 has a FK to Table2 only, not to Table1, and likewise down the chain.

    I have made a form for my users to drill down from Table1-ID to Table4-ID using a series of combo boxes to pick subsequent foreign keys in order to add new records to Table5. However, when the record is saved, only the fields for Table5 should be saved, which includes the FK Table4-ID. The rest of the fields do not pertain to Table5 and so need not be saved.

    I reckon I can achieve this by using one of these two approaches:
    1. Use an unbound form with VBA code to save new records.
    2. Use a compound query of all 5 tables as the form's record source.



    A third way would be to have unbound combo boxes for the first three tables and bound controls for fields in Table5. But again I would have to write code to populate the unbound combos.

    Is there a better way to get round this?

    Regards,
    GoodGuy

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Option 4? Subforms. Five levels is pretty deep. Most I have done is 3 (Form/SubForm/SubSubForm).
    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
    goodguy is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Location
    Zanzibar, Tanzania
    Posts
    229
    Do I have to nest the subforms in each other?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Apparently not. I worked with another poster who set Master/Child links on subforms that were at same level. It seemed to work.
    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.

  5. #5
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    It is easier to deal with the linking if they are nested but they don't have to be. And seven (7) nested subforms is the limit. If they aren't nested, I don't think there is a limit.

  6. #6
    goodguy is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Location
    Zanzibar, Tanzania
    Posts
    229
    Thanks. I understand, and I would like to have all my subforms at one level but as I said earlier, the base tables are chained in a linear fashion, so each lower subform will depend on the preceding one.
    Is this possible without nesting?
    And, is it possible to have a subform on a split form?

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    We have already verified that subforms do not have to be nested. This makes the Master/Child linking a little tricky.

    I expect subform is possible on split form. Try it, let us know what happens. I checked out the split form when 2007 first came out, didn't like it, haven't used.
    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.

  8. #8
    goodguy is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Location
    Zanzibar, Tanzania
    Posts
    229
    The "tricky" bit is what I am dreading, as VBA syntax still plays tricks with my mind and memory.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    VBA is not involved. The Master/Child link properties would reference the key fields in the RecordSources. The complication with not nesting is that the reference has to go through the main form and the container control. I can't find the project I referenced to check this syntax. Maybe boblarsen will offer that.
    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.

  10. #10
    goodguy is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Location
    Zanzibar, Tanzania
    Posts
    229
    Thank you, June7. Does that mean that the Source Object will have to be something other than a table?

  11. #11
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    The source object normally is a form. Also, there may be some VBA involved if you don't nest them, but most of the time I believe you would not need it.

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Doesn't matter if the SourceObject is a table, query, or form. No VBA should be needed. It is a matter of getting the reference in the Master link property correct. Something like: forms!formname.subformcontainername!fieldname
    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.

  13. #13
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664

    I have made a form for my users to drill down from Table1-ID to Table4-ID using a series of combo boxes to pick subsequent foreign keys in order to add new records to Table5. However, when the record is saved, only the fields for Table5 should be saved, which includes the FK Table4-ID. The rest of the fields do not pertain to Table5 and so need not be saved.
    I once started a project along the same lines, but I had 7 levels. Attached is an A2K3 example. There are two forms: a data entry using combo boxes and a list form (using list boxes) that I used to have a better understanding of the relationships. At the bottom of the list boxes are text boxes that show the PK.

    You could set the main form to a record source (table/query) and only bind the last combo/list box to save the Table5 selection to a field. No VBA required.

    My 2cents......



    (BTW, I never finished it. The project was superseded - it was made into a web database.)

  14. #14
    goodguy is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Location
    Zanzibar, Tanzania
    Posts
    229
    Thanks a lot to both of you, June7 and ssanfu. You have been of tremendous help.

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

Similar Threads

  1. Replies: 3
    Last Post: 01-30-2012, 09:43 AM
  2. Cascading field
    By Roger81 in forum Queries
    Replies: 2
    Last Post: 08-02-2011, 11:20 AM
  3. Cascading ?
    By dlburkins in forum Forms
    Replies: 5
    Last Post: 09-27-2009, 04:41 AM
  4. cascading combo form
    By tonysomerset in forum Forms
    Replies: 0
    Last Post: 08-27-2008, 02:10 AM
  5. Replies: 0
    Last Post: 08-13-2008, 03:15 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