Parent-Child Relation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smartchap
    New Member
    • Dec 2007
    • 236

    Parent-Child Relation

    I have a database (in access) having 3 tables: Parent, Child1 & Child2. All the 3 tables have a common field 'PersonID'. Parent table has, say, 10 records having PersonID 1 to 10. Child1 has, say 3 records all having same PersonID, say 5. Child2 has , say 2 records, all having same PersonID, say 5. I want to create a report using DataReport (may be wiith DataEnvironment also) in VB6. The output in report should be like below:
    Record1 of Parent
    Record2 of Parent
    .
    .
    Record5 of Parent
    Record1 of Child1
    Record2 of Child1
    Record3 of Child1
    Record1 of Child2
    Record2 of Child2
    Record6 of Parent
    .
    .
    Record10 of Parent

    For this I think I have to use Shape, Append & Relate commands in the form but don't know how to relate TWO child tables with Parent table.
    Please help me.
    Thanks in advance.

    Always Believe in GOD!
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    simply try to use UNION in sql.

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Originally posted by debasisdas
      simply try to use UNION in sql.
      Yes, you can UNION the two child tables so they look like one big one.

      Comment

      • smartchap
        New Member
        • Dec 2007
        • 236

        #4
        Dear debasisdas and killer42
        UNION is used when both the tables have similar fields. But in my case they have different different fields.
        I used SHAPE command with APPEND and RELATE, it works well with 1 parent & 1 child table, but don't know how to use with one parent & two child tables.
        If there is any other method please help.

        Comment

        • debasisdas
          Recognized Expert Expert
          • Dec 2006
          • 8119

          #5
          Since you are selecting one particular field only that should not be a problem.

          Only they must have same datatype .

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Originally posted by smartchap
            I used SHAPE command with APPEND and RELATE, it works well with 1 parent & 1 child table, but don't know how to use with one parent & two child tables. If there is any other method please help.
            Sorry, you've gone way beyond my SQL knowledge now. I've never even seen SHAPE or RELATE.
            I hope someone else here can help. Also, I'd recommend posting your question in the Access forum, as the real database experts tend to hang around over there.

            Comment

            • smartchap
              New Member
              • Dec 2007
              • 236

              #7
              Dear debasisdas
              All the tables have different different fields and have only one common field PersonID.

              Comment

              Working...