Results 1 to 2 of 2
  1. #1
    shawnjerome is offline Novice
    Windows Vista Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    1

    Union Query of 2 Crosstab

    I am attempting to combine 2 crosstab queries and I keep getting the "Syntax error in TRANSFORM statement".

    TRANSFORM Sum(tblPlanSavings.[PlanSavings]) AS SumOfPlanSavings
    SELECT tblPlanSavings.[BusinessUnit], tblPlanSavings.[PlantName], tblPlanSavings.[Category], Sum(tblPlanSavings.[PlanSavings]) AS [Total Of PlanSavings]
    FROM tblPlanSavings
    GROUP BY tblPlanSavings.[BusinessUnit], tblPlanSavings.[PlantName], tblPlanSavings.[Category]


    PIVOT Format([MonthYear],"mmm") In ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"," Sep","Oct","Nov","Dec")
    UNION ALL
    TRANSFORM Sum(qryProcurementPlantSavingsAllMonths.Savings) AS SumOfSavings
    SELECT qryProcurementPlantSavingsAllMonths.BusinessUnit, qryProcurementPlantSavingsAllMonths.PlantName, qryProcurementPlantSavingsAllMonths.Category, Sum(qryProcurementPlantSavingsAllMonths.Savings) AS [Total Of Savings]
    FROM qryProcurementPlantSavingsAllMonths
    GROUP BY qryProcurementPlantSavingsAllMonths.BusinessUnit, qryProcurementPlantSavingsAllMonths.PlantName, qryProcurementPlantSavingsAllMonths.Category
    PIVOT Format([MonthYear],"mmm") In ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"," Sep","Oct","Nov","Dec");

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,944
    Are you constructing the UNION in VBA or as an Access query object?

    Maybe cannot do all in one sql. Try saving the crosstabs as two Access queries. Then UNION fields from the two 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.

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

Similar Threads

  1. Union Crosstab
    By dssrun in forum Queries
    Replies: 2
    Last Post: 11-14-2011, 10:28 AM
  2. Union Query Help
    By pmp in forum Queries
    Replies: 4
    Last Post: 10-28-2011, 06:41 AM
  3. Help with a Union Query
    By Bear in forum Queries
    Replies: 12
    Last Post: 08-14-2011, 05:12 PM
  4. Union Query Help
    By jo15765 in forum Queries
    Replies: 7
    Last Post: 01-06-2011, 05:46 PM
  5. Please help me out with union query
    By radicrains in forum Access
    Replies: 1
    Last Post: 10-29-2010, 01:48 AM

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