Results 1 to 8 of 8
  1. #1
    vientito is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2014
    Posts
    26

    form/subform relationship

    I have tbl A-> tbl B (1:n) related by a common filed itemID. itemID is unique in A yet could have many in B



    one particular itemID can give rise to two distinct entries in B with same itemID

    so normal viewing of tbl B could have 2*n rows of records

    I have two forms made up FrmA and FrmB. FrmA has a control to take a subform which I match to FrmB. See diagram:

    Click image for larger version. 

Name:	subformprop.gif 
Views:	16 
Size:	12.1 KB 
ID:	18518 where Link Master fields and Link Child fields both referring to itemID.

    Hence my subformB will filter to show only entries that have a particular itemID

    On FrmB there are lots of events I can exploit to maniuplate my records but on a form level

    On FrmA if I refer to subform which is linked to FrmB I only am offered two events to code (On Enter and On Exit)

    I would like to insert my own controls on FrmB and manipulate the recordsets to show/update my data. If I invoke CurrentDB, I will assume that it will contain the full recordset without any filter on its source (from TBL B : 2* n rows)

    Yet I know if FrmB is operating as a subform in FrmA it is only handed over 2 records according to which itemID I am looking at. So does it mean that the routines that I have coded under FrmB rely on a currentDB recordset that can vary, depending whether it is in the context of a subform or as a form?

    Or do I have to do something explicit using On Enter under the subform control to pass this knowledge to FrmB?

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    mmmm my initial impression is that I either can't understand your question or that you are over-thinking the situation.....

    the classic MainForm:SubForm set up via the wizard puts into place what is needed and requires no additional custom code.....

    this at least is the starting point; as to what additional modifications to this core design might be needed I do not understand from your post......

  3. #3
    vientito is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2014
    Posts
    26
    All my controls on FrmB are unbounded. I need to access the recordset to work with the users.

    From FormB I need to access not the full records but only those records corresponding to the ID flagged in the main form

    How do I get that recordset?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,630
    Unbounded controls - why?

    The subform is filtered by the ID because of the Master/Child links. If you use the subform's RecordsetClone, that will be filtered recordset.
    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
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    set up the Main form in a normal fashion i.e. with a record source of its table A

    make a 2 form also in a normal fashion i.e. with a record source of its table B

    then return to the Main form, in design view, insert the 2nd form - making it a sub form - this task will launch the wizard which will seek to match the cross referencing field between the 2 tables.

    upon doing this then for whichever record is selected in the Main form - the related records of the table B will appear within the 2nd sub form....

    this is vanilla Access set up

    get that working first before considering any further modifications.

  6. #6
    vientito is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2014
    Posts
    26
    Quote Originally Posted by June7 View Post
    Unbounded controls - why?

    The subform is filtered by the ID because of the Master/Child links. If you use the subform's RecordsetClone, that will be filtered recordset.

    That's fine as long as I am referring to this recordsetclone from the perspective of the Main form. Me.subform.form.recordsetclone is essentially a pointer known in Main only, right?

    The problem is that I need to watch for events with these controls on the subform. Only two events are offered "On entry" & "On exit" for this subform.

    For instance, I need to hook an event where a user will type in text on this subform and this need to be fed back to the database (the filtered recordset)

    Do I simply call recordsetclone assuming this is what I get through the Main form?

    What happens when there is no parent form (main form) that invokes it? Would recordsetclone be Null?

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,630
    A subform is created by placing a subform container control on another form and then setting the SourceObject property. The container has only the two events, however, the form that is referenced in the SourceObject still has all the events associated with any form.

    Every bound form (main or otherwise) has a RecordsetClone and can be referenced from anywhere.

    I don't understand what you need. If the subform is bound then any data entry/edit will automatically 'be fed back to the database'.
    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
    vientito is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2014
    Posts
    26
    Quote Originally Posted by June7 View Post
    A subform is created by placing a subform container control on another form and then setting the SourceObject property. The container has only the two events, however, the form that is referenced in the SourceObject still has all the events associated with any form.

    Every bound form (main or otherwise) has a RecordsetClone and can be referenced from anywhere.

    I don't understand what you need. If the subform is bound then any data entry/edit will automatically 'be fed back to the database'.
    Thanks I think I have cleared that up now.

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

Similar Threads

  1. Replies: 2
    Last Post: 11-16-2012, 02:29 PM
  2. Form and Subform relationship
    By ZJGMoparman in forum Forms
    Replies: 1
    Last Post: 04-16-2012, 12:25 AM
  3. Form/Subform relationship help
    By bkirsch in forum Forms
    Replies: 13
    Last Post: 01-27-2012, 01:24 PM
  4. Form/Subform relationship
    By justhininabouti in forum Forms
    Replies: 2
    Last Post: 11-28-2011, 09:07 PM
  5. Replies: 0
    Last Post: 02-16-2006, 09:11 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