Troubles creating parameters for a report

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • apartain
    New Member
    • Nov 2006
    • 58

    Troubles creating parameters for a report

    My database is based on Work Order Numbers. If an employee enters labor, they must include the WO Number for it. Equipment, subcontractors, per diem and materials all must also have a WO number.

    I have the following tables:
    Work Orders
    Labor (includes per diem and time entries)
    Equipment
    Subcontractors
    Materials

    I have created a summary report using the Materials table which lists the WO number, total labor, total equipment, total subc's, and total materials, if any, within a user-specified date range.

    The totals of labor, per diem, equipment, subc's and materials use the DSum function.

    The problem is that since I created the report based off of the Work Orders table, it lists all of the work orders, not just the ones which have transactions from any or all of the other tables. Is there some SQL or a query I can create to only show the work orders which have transactions from the other tables during the specified date range?
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Inner join the other tables.

    Comment

    • apartain
      New Member
      • Nov 2006
      • 58

      #3
      Originally posted by Rabbit
      Inner join the other tables.
      I'm sure this is something easy to do, but I can not figure it out. I tried it in a query where I included the WO, labor, equipment and materials tables. Zero records appear. I tried multiple queries with WO and labor, WO and equip, etc., which seemed to work but then I could not join THOSE queries.

      What I want is to view a report which shows only those work order numbers that had activity for that time period. There may or may not be labor, there may or may not be materials, but if there is anything at all I want the WO to appear on the report with the corresponding information.

      Could you give more detail on how to accomplish the inner join between the tables?
      Thank you.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        If they don't have a record in each table then a join won't work. I would say make a query for each table and join on only one table and then union them but a union requires that they all have the same field names. Will that be a problem?

        Comment

        • apartain
          New Member
          • Nov 2006
          • 58

          #5
          Originally posted by Rabbit
          If they don't have a record in each table then a join won't work. I would say make a query for each table and join on only one table and then union them but a union requires that they all have the same field names. Will that be a problem?
          They all have the field name "Work Order Number".

          There are some other like fields such as date, ID, etc. but that's it.

          How does a union query work?

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            A union query takes the unique records from different tables. A union all allows repeats.

            Code:
            [b]Table1[/b]
            LastName  SomeNum
            Doe       1
            Moe       2
            Schmoe    3
            
            [b]Table2[/b]
            LastName  SomeNum
            Doe       1
            Moe       4
            
            [b]Union Results[/b]
            LastName  SomeNum
            Doe       1
            Moe       2
            Schmoe    3
            Moe       4
            
            [b]Union All[/b]
            LastName  SomeNum
            Doe       1
            Moe       2
            Schmoe    3
            Doe       1
            Moe       4

            Comment

            Working...