Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2004
    Posts
    364

    Unanswered: How to link two subforms?

    Hello,

    I have three forms, a mainFrm, subFrm1 and subFrm2 (both subforms are set to continuous).

    The MainFrm control source field is itemID, the subFrm1 control source is LinkItemID and the control source of subFrm2 is also LinkItemID.

    I would like to know how I can link the two subforms to enable subFrm2 to display linkItemId records when a row is selected in subFrm1.

  2. #2
    Join Date
    May 2010
    Posts
    601
    Quote Originally Posted by moss2076 View Post
    Hello,

    I have three forms, a mainFrm, subFrm1 and subFrm2 (both subforms are set to continuous).

    The MainFrm control source field is itemID, the subFrm1 control source is LinkItemID and the control source of subFrm2 is also LinkItemID.

    I would like to know how I can link the two subforms to enable subFrm2 to display linkItemId records when a row is selected in subFrm1.
    Yes it is possible to do. It is similar to cascading combo/list boxes.

    In the second sub form, set the master linking field to be a form reference to a control in the first sub form.

    In the first sub form, use the On Current event to requery the second sub form. (example: Me.Parent.SubForm2Name.form.requery )
    Boyd Trimmell aka HiTechCoach HiTechCoach.com (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  3. #3
    Join Date
    Aug 2004
    Posts
    364
    I cannot get your suggested code to work -
    Code:
    Me.Parent.frmQryTest.Form.Requery
    I get a run time error 2455 You entered an expression that has an invalid reference to the property form/report. So for some reason the code isnt referring to the second subform correctly.

    The main form is called frmItem, the first subform is called subFrmItem, and the second subform which I want to requery is called frmQryTest, so I dont know why this method isnt working.

    I have found another method which does work, although it involves having to place an unbound textbox (txtTest) on the main form (frmItem), setting the textbox control source to the first subform -
    Code:
    =subfrmItem.Form!linkLocationItemID
    and then linking the child and master fields of the second subform (frmQryTest) to the field (linkLocationID) and the textbox.

  4. #4
    Join Date
    Aug 2004
    Posts
    364
    I got it working with this code in the on current event -
    Code:
    Forms![frmitem].Form![frmQryTest].Requery

  5. #5
    Join Date
    May 2010
    Posts
    601
    Glad to hear you got it working.
    Boyd Trimmell aka HiTechCoach HiTechCoach.com (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •