Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 512
  • Last Modified:

Modify access query to replace value with an "X"

Hi, I am trying to modify the query to subsitute the letter X for the Crosstab value.  Goal: if the same description is listed under one or more ActivityClasses Categories (Age groups) then place a X under the heading instead of the Autonumber row ID that is associated with a Activity Description.

This is what I have below and I was trying to use with the existing query by placiing it in the Value Criteria field but no luck.  Please tell me what I am dointg wrong.  The ActivityDescription field is a text field, the AQctivityField is a Text field and the ID field is a autonumber field.

IIf(IsNotNull),"substitute text",[X])

Existing Results
*******************
ActivityDescription                       5_6AgeGroup    7_10AgeGroup   11-15ageGroup
Jump off a rope                                       3                       13                         48                              
swim around the park.until dark                                                                     5

Goal Results  
***************
ActivityDescription                       5_6AgeGroup    7_10AgeGroup   11-15ageGroup
Jump off a rope                                       X                        X                         X                              
swim around the park.until dark                                                                    X

Thank you in advance,
TRANSFORM First([tblDetail].ID) AS FirstOfID
SELECT [tblDetail].ActivityDescription
FROM [tblDetail]
GROUP BY [tblDetail].ActivityDescription
PIVOT [tblDetail].ActivityClass;

Open in new window

0
cesemj
Asked:
cesemj
  • 4
  • 3
1 Solution
 
pteranodon72Commented:
(assuming your ActivityClass fields are fixed, you can:

Leave your crosstab query as it is (existing results), and let's pretend it is named qryCT.

Create a new Select Query:

SELECT ActivityDescription, Iif(IsNull([5_6AgeGroup], "", "X"), Iif(IsNull([7_10AgeGroup], "", "X"), Iif(IsNull([11_15AgeGroup], "", "X") FROM qryCT


HTH,

pT
0
 
pteranodon72Commented:
Of course, you may want to alias the fields:

SELECT ActivityDescription,
Iif(IsNull([5_6AgeGroup], "", "X") AS [5_6Group],
Iif(IsNull([7_10AgeGroup], "", "X") AS [7_10Group],
Iif(IsNull([11_15AgeGroup], "", "X") AS [11_15Group]
FROM qryCT;

HTH,
pT
0
 
cesemjAuthor Commented:
Correct me if I am wrong the table that contains the ActivityClases are fixed because the field valuse do not change.  I will try the concept and let you know how things turn out.

Thanks
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
cesemjAuthor Commented:
I receive Syntax Error (missing operator) in query expression 'SELECT ActivityDescription, Iif(IsNull([5_6AgeGroup], "", "X"), Iif(IsNull([7_10AgeGroup], "", "X"), Iif(IsNull([11_15AgeGroup], "", "X") FROM qryCT'

What do you think I did wrong.
0
 
Chuck WoodCommented:
Shouldn't you be using FROM tblDetail instead of qryCT?
0
 
cesemjAuthor Commented:
I receive the same error:
 I receive Syntax Error (missing operator) in query expression 'SELECT ActivityDescription, Iif(IsNull([5_6AgeGroup], "", "X"), Iif(IsNull([7_10AgeGroup], "", "X"), Iif(IsNull([11_15AgeGroup], "", "X") FROM qrytblDetalCrosstab'

Thanks
0
 
pteranodon72Commented:
Sorry, there -- missed some closing parentheses for IsNull.  Try:

SELECT ActivityDescription,
Iif(IsNull([5_6AgeGroup]), "", "X") AS [5_6Group],
Iif(IsNull([7_10AgeGroup]), "", "X") AS [7_10Group],
Iif(IsNull([11-15AgeGroup]), "", "X") AS [11-15Group]
FROM qrytblDetalCrosstab;


You may need to play with the exact text within [] to match your data -- I now see that there is an underscore in the first two groups but a hyphen in the third.  The paren problem was totally my fault, though.

pT
0
 
cesemjAuthor Commented:
Thank you for helping me underatand.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now