Subform Record Problem

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

    #1

    Subform Record Problem

    have a main form with two tabs, and each tab has a subform. The first
    tab's subform refers to the mainform (this works). The second tab's
    subform refers to the identity key of the first tab's subform.

    I can't get the second subform to show the proper records. I have
    used the child and masterlink fields. I have set the recordsource of
    the second subform to include the identity key field on the first
    subform.

    This an accounting system and is running many calculations. If I try
    to requery the subform using the oncurrent on the first subform it
    crashes. I've tried to set the recordsource in different places and
    can't get it to work properly.

    The closest I came was to put the recordsource dynamically on the
    tabmain code. But that only returned one record in the second subform
    instead of all the correct records.

    At this point I'm stuck. Any help would be appreciated.

  • storrboy

    #2
    Re: Subform Record Problem



    How are you setting the Child/Master links between subforms?

    Comment

    • christianlott1@yahoo.com

      #3
      Re: Subform Record Problem

      Make the subform's recordsource the result of a query. Set the the
      query parameter on the matching field main key to subform foreign key.

      forms!form1!key _value

      in 'criteria' box under the foreign key's column in the query.

      Comment

      • Tom Clavel

        #4
        Re: Subform Record Problem

        On Feb 19, 5:06 pm, "Ecohouse" <ecovinda...@ya hoo.comwrote:
        have a main form with two tabs, and each tab has a subform. The first
        tab's subform refers to the mainform (this works). The second tab's
        subform refers to the identity key of the first tab's subform.
        >
        I can't get the second subform to show the proper records. I have
        used the child and masterlink fields. I have set the recordsource of
        the second subform to include the identity key field on the first
        subform.
        make an unbound field on the parent form called txtKey

        Access hates to use an unbound field as master field, you can do it.
        Make txtKey your master field for the second (non-working) subform.
        You can't use the wizard to build this relationship, and any time you
        try to use the wizard it will clear the relationship.

        in the first (working) subform's onCurrent event:
        me.parent!txKey = me!txtID


        Comment

        • Ecohouse

          #5
          Re: Subform Record Problem

          Thanks for all the help. I've tried using all of the suggestions and
          none of them work. This form is complicated and runs a lot of
          calculations and updates when it moves from record to record and
          subform to subform.

          I put an unbound field on the main form and it caused the form to
          crash. I am using the master-child links also and that returns all
          the records.

          I've also set the recordsource dynamically. This is the closest I've
          come. But the problem is that it only returns one record instead of
          all of them. This is the code:

          Private Sub TabMain_Change( )

          Dim strsql As String

          If Me.Dirty Then Me.Dirty = False

          If Me.TabMain.Valu e = 2 Then
          strsql = "SELECT ProjectData.* FROM ProjectData WHERE " & _
          "([ProjectData].[EngagementSK]= " & [Forms]!
          [ClientInformati on]![subEngagementIn formation].Form!SK & "); "

          Me![subProjectInfor mation].Form.RecordSou rce = strsql

          Me.subProjectIn formation.Form. Refresh
          End If

          I can't use a requery here because it causes the form to crash. Any
          other ideas?



          End Sub

          Comment

          Working...