Page 2 of 9 FirstFirst 123456789 LastLast
Results 16 to 30 of 132
  1. #16
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    Then the RowSource sql would be an aggregate query that groups on Technician Name and Sum each activity hours.

    SELECT Table1.[Technician Name], Sum(Table1.[A1 L1]) AS [SumOfA1 L1], Sum(Table1.A1L2) AS SumOfA1L2, Sum(Table1.A1L3) AS SumOfA1L3
    FROM Table1
    WHERE (((Table1.[Technician Name])=[Forms]![Par-Pak final].[Technician Name]))


    GROUP BY Table1.[Technician Name];
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  2. #17
    Sonny101 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jun 2014
    Posts
    79
    I type in this statement and get an error regarding punctuation:


    SELECT Table1.[Technician Name], Sum(Table1.[A1 L1]) AS [SumOfA1 L1], Sum(Table1.A1L2) AS SumOfA1L2, Sum(Table1.A1L3) AS SumOfA1L3, Sum(Table1.A1L4) AS SumOfA1 L4, Sum(Table1.A1L5) AS SumOfA1L5, Sum(Table1.[A1 Anc]) AS [SumOfA1 Anc], Sum(Table1.A2L1) AS SumOfA2L1, Sum(Table1.A2L2) AS SumOfA2L2, Sum(Table1.A2L3) AS SumOfA2L3, Sum(Table1.A2L4) AS SumOfA2L4, Sum(Table1.A2L5) AS SumOfA2L5, Sum(Table1.[A2 Anc]) AS [SumOfA2 Anc], Sum(Table1.[A3 Inv]) AS [SumOfA3 Inv], Sum(Table1.[A3 Shop]) AS [SumOfA3 Shop], Sum(Table1.[A3 Facility]) AS [SumOfA3 Facility], Sum(Table1.[A3 Housekeeping]) AS [SumOfA3 Housekeeping], Sum(Table1.[A4 Installation]) AS [SumOfA4 Installation], Sum(Table1.[A4 Preparation]) AS [SumOfA4 Preparation], Sum(Table1.[A5 Discuss]) AS [SumOfA5 Discuss], Sum(Table1.[A5 Inspec]) AS [SumOfA5 Inspec], Sum(Table1.[A5 manual]) AS [SumOfA5 manual], Sum(Table1.[A5 Specify]) AS [SumOfA5 Specify]
    FROM Table1
    WHERE (((Table1.[Technician Name])=[Forms]![Par-Pak final].[Technician Name]))
    GROUP BY Table1.[Technician Name];



    Any ideas Thanks for the code though

  3. #18
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    Why are you typing statement? Use the query builder. Click the ellipsis (...) to open.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #19
    Sonny101 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jun 2014
    Posts
    79
    Oh so thats what you meant, lol sorry my bad So when I select the fields from the box how do i select them as "sums"? . They just appear as normal fields not "SumOf...' something. And also what do you mean by WHERE and GROUP BY?
    Attached Thumbnails Attached Thumbnails Capture.jpg  

  5. #20
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    Click Totals (with the Sigma symbol) on the Design ribbon.

    WHERE clause is filter criteria. Enter parameters on the Criteria row.

    The Total row will be available after clicking Totals. Select GROUP BY or SUM as appropriate.

    Access Help has more guidelines on using the query builder for the various types of queries.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #21
    Sonny101 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jun 2014
    Posts
    79
    You mean like this?

    Sorry these long office hours are killing me here Can't even get a single thing done
    Attached Thumbnails Attached Thumbnails Capture.jpg   Capture.jpg  

  7. #22
    Sonny101 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jun 2014
    Posts
    79
    Oh nevermind got it. Had a typo in the code which was causing the error Thanks for all the help. One final thing, is it possible that when I view the graph in preview mode, the name of Technician shows up? Also when I print it there is a timestamp as to when this was printed?

  8. #23
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    The db you provided has the technician name in the table. If this is not the actual data structure, then include the table with technician name in the query and join the tables on the common TechnicianID fields. This will make the name available for the query design grid.

    Textbox on report can have expression in ControlSource property: = Now()

    The filter criteria should be under only the TechnicianName field, not each of the hours fields.
    Last edited by June7; 07-17-2014 at 01:54 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #24
    Sonny101 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jun 2014
    Posts
    79
    Quote Originally Posted by June7 View Post
    A field for each activity is not normalized data structure. Cannot get the graph you want with this table structure. Should be like:
    Tech Act Hrs Date Shift Crew
    1 A 4 7/15/2014 1 1
    1 B 5 7/15/2014 1 1
    1 C 3 7/15/2014 1 1
    1 D 6 7/16/2014 1 2
    1 E 2 7/17/2014 1 1
    2 A 4 7/15/2014 1 1
    2 B 7 7/16/2014 1 3
    2 C 3 7/16/2014 2 1
    2 D 2 7/17/2014 1 1

    It is possible to manipulate the data to a normalized structure with UNION query then use the UNION as source for graphing. UNION must be typed or copy/paste in SQL View of query builder. For some reason, I cannot type UNION in the example query. Replace ______ with UNION.
    SELECT ID, [Technician Name] AS Tech, [Date], Crew, Shift, "A1L1" As Act, [A1 L1] AS Hrs FROM Table1
    ______ SELECT ID, [Technician Name], [Date], Crew, Shift, "A1L2", [A1L2] FROM Table1
    ______ SELECT ID, [Technician Name], [Date], Crew, Shift, "A1L3", [A1L3] FROM Table1;

    Pie graph RowSource:
    SELECT UnionT1.Act, Sum(UnionT1.Hrs) AS SumOfHrs FROM UnionT1 WHERE (((UnionT1.Tech)=[Forms]![Par-Pak final].[Technician Name])) GROUP BY UnionT1.Tech, UnionT1.Act;

    Correction. If you want bar chart then your table can work. (A normalized structure would actually require a CROSSTAB query for bar graph. Applying filter criteria in CROSSTAB is different from other queries.) The graph RowSource would be like:
    SELECT [Date], [A1 L1], A1L2, A1L3 FROM Table1 WHERE ((([Technician Name])=[Forms]![Par-Pak final].[Technician Name]));

    Date is a reserved word. Should not use reserved words as field names. Also, should avoid spaces and special characters/punctuation (underscore is exception) in naming convention. Note the space in [A1 L1].


    The bar-graph worked perfectly, I spent the weekend on designing it and looks good But now for the pie-chart I was looking at this post and wanted to know that what you meant by "UNION must be typed or copy/paste in SQL View of query builder". Plus where am I to write. Plus what about this code which follows

    "
    SELECT ID, [Technician Name] AS Tech, [Date], Crew, Shift, "A1L1" As Act, [A1 L1] AS Hrs FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "A1L2", [A1L2] FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "A1L3", [A1L3] FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "A1L4", [A1L4] FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "A1L5", [A1L5] FROM Table1

    "

  10. #25
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    That is a UNION query sql statement. There is no wizard or designer for UNION. Open query builder and switch to SQL View. Type the SQL statement (or copy/paste the example) into the edit window.

    However, if you the technician name is actually in another table, then each SELECT statement of the UNION can be an sql that joins the appropriate tables. Can use the query builder design grid to help you get the correct structure for the SELECT with joined tables. Then copy/paste the SELECT sql into the SQL View window and make edits as needed.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #26
    Sonny101 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jun 2014
    Posts
    79
    Ok I wrote the following statement in the sql view,



    SELECT ID, [Technician Name] AS Tech, [Date], Crew, Shift, "A1L1" As Act, [A1 L1] AS Hrs FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "A1L2", [A1L2] FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "A1L3", [A1L3] FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "A1L4", [A1L4] FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "A1L5", [A1L5] FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "A1 Anc", [A1 Anc] FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "A2L1", [A2L1] FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "A2L2", [A2L2] FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "A2L3", [A2L3] FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "A2L4", [A2L4] FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "A2L5", [A2L5] FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "A2 Anc", [A2 Anc] FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "Inventory", [A3 Inv] FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "Shop", [A3 Shop] FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "Facility", [A3 Facility] FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "Housekeeping", [A3 Housekeeping] FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "Installation", [A4 Installation] FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "Preparation", [A4 Preparation] FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "Discussion", [A5 Discuss] FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "Inspection", [A5 Inspec] FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "Manual", [A5 manual] FROM Table1
    UNION SELECT ID, [Technician Name], [Date], Crew, Shift, "Other(Specified)", [A5 Specify] FROM Table1;


    Saved the querry as "UNION", went to reports>New>Chart Wizard, and selected the "UNION" query as to where the data comes from> Properties> RowSource and typed the following code

    SELECT UnionT1.Act, Sum(UnionT1.Hrs) AS SumOfHrs FROM UnionT1 WHERE (((UnionT1.Tech)=[Forms]![Par-Pak final].[Technician Name])) GROUP BY UnionT1.Tech, UnionT1.Act;

    But was greeted by this error

    Any Ideas
    Attached Thumbnails Attached Thumbnails Capture.JPG  

  12. #27
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    You named the query "UnionT1"?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #28
    Sonny101 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jun 2014
    Posts
    79
    Oh shoot my bad. Although this works , but is there any way to group the activities together, as the pie chart is cluttered with different categories? As in if I want to group all the A1 together(sum of all their individual activities such as A1L1 + A1L2 + A1L3 +A1L4 etc), and compare them with A2, A3? Also then create charts for A1, A2, A3, A4 repectively (Meaning for eg a chart containing only A1L1, A1L2, A1L3, A1L4, A1L5 A1 Anc)

  14. #29
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    Create another field in the UNION, something like:

    "A1" AS Category
    ...
    "A2"
    ...
    "A3"
    ...
    "A4"
    ...
    "A5"

    Then the graph RowSource sql can be an aggregate query to include that field and group on it instead of Act field.

    Create fields as needed for whatever level of aggregation you want.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #30
    Sonny101 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jun 2014
    Posts
    79
    So if I create one more field, how do I group 4 or more fields into that one(by summing them) Could you write the code for one of those groups so I can replicate them further to suit my needs. Also can you plz explain what you meant by RowSource sql being an aggregate query?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Graph on Form - Overriding data
    By Gabriel2012 in forum Forms
    Replies: 6
    Last Post: 02-19-2013, 10:18 AM
  2. Replies: 6
    Last Post: 02-29-2012, 03:13 AM
  3. How to program a GRAPH out of data from TABLE
    By taimysho0 in forum Programming
    Replies: 7
    Last Post: 02-15-2012, 04:09 PM
  4. Replies: 3
    Last Post: 01-10-2011, 10:31 AM
  5. Graph totals queries with different data
    By maggioant in forum Queries
    Replies: 0
    Last Post: 10-01-2009, 12:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums