Synchronizing Two Subforms

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tom

    #1

    Synchronizing Two Subforms

    The purpose of my form is to record multiple owners of businesses. The main form
    displays the business records. Subform1 is a continuous form consisting of only
    a combobox to select owners from a table of owners. Subform1 contains record
    selectors so after owners are entered, a specific owner can be selected. PK is
    OwnerID. Subform2 is a single form based on the same owner table and its purpose
    is to display details about the selected owner in Subform1. Foreign key is
    OwnerID.

    Since Subform1 is a continuous form, I have Subform2 external to Subform1. What
    needs to be done so that as specific owners are selected in Subform1, Subform2
    displays the related details about the owner selected inSubform1?

    Thanks,

    Tom


  • paii, Ron

    #2
    Re: Synchronizing Two Subforms

    Why don't you make subform 1 the main from and link subform2 (Detail
    records) to the main form on OwnerID?

    "Tom" <tharkless@bell south.net> wrote in message
    news:U_rpb.3584 $Oo4.1037@newsr ead1.news.atl.e arthlink.net...[color=blue]
    > The purpose of my form is to record multiple owners of businesses. The[/color]
    main form[color=blue]
    > displays the business records. Subform1 is a continuous form consisting of[/color]
    only[color=blue]
    > a combobox to select owners from a table of owners. Subform1 contains[/color]
    record[color=blue]
    > selectors so after owners are entered, a specific owner can be selected.[/color]
    PK is[color=blue]
    > OwnerID. Subform2 is a single form based on the same owner table and its[/color]
    purpose[color=blue]
    > is to display details about the selected owner in Subform1. Foreign key is
    > OwnerID.
    >
    > Since Subform1 is a continuous form, I have Subform2 external to Subform1.[/color]
    What[color=blue]
    > needs to be done so that as specific owners are selected in Subform1,[/color]
    Subform2[color=blue]
    > displays the related details about the owner selected inSubform1?
    >
    > Thanks,
    >
    > Tom
    >
    >[/color]


    Comment

    • andybriggs

      #3
      Re: Synchronizing Two Subforms


      The general idea is to set the RecordSource property of Subform2 to
      select the one record that matches the record in Subform1. When a record
      is selected in the control on Subform1, attach a procedure to its
      "AfterUpdat e" event to select the record in Subform2. It would look
      something like:



      Sub Subform1Control Name_AfterUpdat e()



      Forms!NameOfMai nForm!NameOfSub form2.Form.Reco rdSource = _

      "SELECT * FROM NameOfTableOrQu ery WHERE OwnerID = " _

      & Forms!NameOfMai nForm!NameOfSub form1.Form! ControlNameInSu bform1



      End Sub





      This selects the one record in Subform2 that matches the OwnerID
      selected in Subform1. Don´t forget that if the OwnerID is text then you
      need to modify the SQL slightly to read :



      Forms!NameOfMai nForm!NameOfSub form2.Form.Reco rdSource = _

      "SELECT * FROM NameOfTableOrQu ery WHERE OwnerID = ´" _

      &Forms!NameOfMa inForm!NameOfSu bform1.Form! ControlNameInSu bform1 &"´"



      I hope this helps.


      --
      Andy Briggs
      Elmhurst Solutions Limited
      Elmhurst Solutions offers a range of bespoke introduction and consulting services to a broad spectrum of corporate and individual clients, optimising supply chains & facilitating access to developing and emerging markets. With a competitive fee structure and a proven network…



      Posted via http://dbforums.com

      Comment

      Working...