Results 1 to 4 of 4
  1. #1
    survivo01 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    71

    Crosstab query, I want to select column using list

    I have a crosstab query called Enrolled crosstab. ABE, GED, Conflict represent a column in the crosstab query. I want to be able to select the column with a drop down list
    Enrolled crosstab
    ABE
    GED
    Conflict

    Field ID ABE
    Table Enrolled crosstab
    Sort
    Show
    Criteria is null

    What I can't figure out how to do is change the red field to ABE, GED, Conflict

    Here is the Crosstab query
    Enrolled
    ID
    Mod
    Enroll type
    TRANSFORM First(enrolled.[Enroll Type]) AS [FirstOfEnroll Type]
    SELECT enrolled.ID
    FROM enrolled
    GROUP BY enrolled.ID
    PIVOT enrolled.[Mod];


    FIELD ID MOD ENROLL TYPE
    TABLE ENROLLED ENROLLED ENROLLED
    TOTAL GROUP BY GROUP BY FIRST
    CROSSTAB ROW HEADING COLUMN HEADING VALUE


    The result is
    Last edited by survivo01; 07-23-2013 at 01:59 PM. Reason: additional info

  2. #2
    Dal Jeanis is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Post the full SQL for the crosstab query.

  3. #3
    survivo01 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    71
    Here is the Crosstab query
    Enrolled
    ID
    Mod
    Enroll type
    TRANSFORM First(enrolled.[Enroll Type]) AS [FirstOfEnroll Type]
    SELECT enrolled.ID
    FROM enrolled
    GROUP BY enrolled.ID
    PIVOT enrolled.[Mod];
    FIELD ID MOD ENROLL TYPE
    TABLE ENROLLED ENROLLED ENROLLED
    TOTAL GROUP BY GROUP BY FIRST
    CROSSTAB ROW HEADING COLUMN HEADING VALUE

  4. #4
    Dal Jeanis is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742

    Three Options for you

    Okay, so there are three methods and any method is about the same amount of work.
    1) The first is the simplest, conceptually. It's not elegant, but it has the advantages of simplicity and certainty.

    You can code four different crosstabs and have the dropdown cause the source of the subform display to be replaced with the selected query.

    2) The second requires a little bit more comfort with code, but, again, it can be accomplished with certainty.

    You can set up VBA to take the SQL for one crosstab, and have the spot in the SQL now held by Mod instead be provided by a string variable that contains the name of the desired field.

    3) The third would require some testing, but would be the most elegant of the three methods, if the syntax of a crosstab query would allow it. I can't guarantee that it will, because crosstabs are finnicky.

    You can have the dropdown set a temp variable, and have an IIF set the value of your Pivot field based on the value of the temp variable.

    Something like this...
    IIF([TempVars]![CrossChoice]="Mod",enrolled.[Mod],[TempVars]![CrossChoice]="ABE",enrolled.[ABE],...)

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

Similar Threads

  1. Replies: 14
    Last Post: 12-15-2012, 02:59 AM
  2. Replies: 1
    Last Post: 05-24-2012, 10:21 AM
  3. Replies: 3
    Last Post: 02-21-2012, 10:15 AM
  4. Crosstab Query - Column differences conflict
    By JoshZulaica in forum Queries
    Replies: 1
    Last Post: 06-23-2011, 01:43 AM
  5. Replies: 20
    Last Post: 02-14-2011, 10:55 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