Solved

Formatting data in a crosstab query

Posted on 2014-03-14
5
362 Views
Last Modified: 2014-03-20
I have created a select query where I calculate the % of pupils working at a certain level in each subject.

I now want to create a crosstab query with the level as a row heading and subject as a column heading and display the % of pupils but although it is formatted as % in the select query and displays correctly in does not display this way in the crosstab query

Level      Art      Drama
      0.809836065573771      0.809836065573771
2      0.101639344262295      9.50819672131148E-02
3      8.85245901639344E-02      9.50819672131148E-02

Even though I got to properties and select format > percentage it does not seem to work.

Tricia
0
Comment
Question by:tmckeating
  • 3
  • 2
5 Comments
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39930573
Are you perhaps using the NZ( ) function anywhere in the query(s) that generate this?

When used in a query, the NZ( ) function will return a string, and when you try to format the string as %, in the query designer, it will not work.  If you use NZ( ), try wrapping it in a type conversion functions, something like cdbl(NZ([field name]))  and see if that works.
0
 

Author Comment

by:tmckeating
ID: 39931141
I am not using NZ anywhere in the query and adding cdbl does not appear to do anything.

Tricia
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 250 total points
ID: 39931174
can you provide the SQL for the queries (multiple SQL Statements if nested) that generate these values.

What does the data look like before you do the crosstab?  Is it normalized like:

Level   Course    Pct
1          Art           0.809836065573771
1          Drama     0.809836065573771
2          Art           0.101639344262295
2          Drama    9.50819672131148E-02
3          Art           8.85245901639344E-02
3          Drama    9.50819672131148E-02

I normally prefer to use the query design grids formatting properties Query column formmatingbut on occasion will actually use the Format( ) function to force query output into a format that I'm not able to get with the query format parameter.  You might try using a format like:

format([Pct], "#0.0000%") in the query that creates the cross-tab
0
 

Author Closing Comment

by:tmckeating
ID: 39941931
I was using the formatting properties as you showed above but that did not work ...the format() function worked superbly. Thanks again for your help.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39942221
Glad I could help.

You just need to make sure your understand that the Format( ) function returns a string, not a number, whereas using the Format property of the query affects the way the data is displayed, but will retain it's actual value.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question