Results 1 to 2 of 2
  1. #1
    scottc_00 is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2015
    Posts
    5

    Create expression using switch() in a Summation query

    I have a query that creates an expression using a switch function and it works perfectly. What it does is combine 3 columns of data into one. I am now trying to use the exact same expression in another query and it is failing. The only difference is that the query it works in is a Simple Select query. The query it is failing in is a Summation query.



    The summation query Groups ALL fields and sums (counts) the rows in each grouping.

    This is the Switch()
    HC_lvl678: Switch([Lvl 6]="Baseball","Baseball",[ Lvl 7]="Football","Football",[Lvl 7]="Basketball","Basketball",[Lvl 7]="Soccer","Soccer",[Lvl 8]="Hockey”,"Hockey",[Lvl 8]="Golf","Golf")

    This is the Error I am getting
    Syntax error (comma) in query expression ‘TableName.[ Switch([Lvl 6]="Baseball","Baseball",[ Lvl 7]="Football","Football",[Lvl 7]="Basketball","Basketball",[Lvl 7]="Soccer","Socc’.

    Is it even possible to include an expression in a summation query?
    Is it too long (it looks like its cut off but that may be a limitation in the mssg)?


    Thanks

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,901
    Why do you have 8 fields with similar data? This is not normalized structure.

    Do the expression in SELECT query then use that query as the source for aggregate query.

    Or build a report and use its Grouping & Sorting features with aggregate calcs in header/footer sections. Report allows display of detail records as well as summary data.
    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. Replies: 1
    Last Post: 07-24-2014, 08:35 PM
  2. Replies: 1
    Last Post: 12-23-2013, 02:30 PM
  3. Replies: 2
    Last Post: 10-15-2013, 07:50 AM
  4. Replies: 3
    Last Post: 12-02-2012, 12:59 AM
  5. Replies: 4
    Last Post: 10-26-2012, 12:49 AM

Tags for this Thread

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