473,416 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Group by Calculated Field?

I am using Access 2000.

One table in my database has a field called RankName.
Values inlcude: Officer, Sergeant, Lieutenant.
I need create a report that groups these three RankNames into two
groups: those that are Supervisors (Sergeant, Lieutenant) and those
that are Not Supervisors (Officers).

Is there a way I can create a calculated field in a query that does
something like this ...

If the value in the member's RankName field is Sergeant or Lieutenant
return a value of "Supervisor"
If not
Return a value of "Officer"

Then can I Group By the value in this calculated field: Supervisor or
Officer?

I am not sure that this is possible or how best to go about achieving
this grouping.

Any help would be appreciated.
Thanks
John

Mar 22 '06 #1
2 5906
How about adding another field to the table that has the RankNames field--a
yes/no field named IsSupervisor. Check the boxes for the ranks that are
supervisors.

Then add this field to your query, and in the report you can group by the
IsSupervisor field.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"John" <jo*******@sbcglobal.net> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
I am using Access 2000.

One table in my database has a field called RankName.
Values inlcude: Officer, Sergeant, Lieutenant.
I need create a report that groups these three RankNames into two
groups: those that are Supervisors (Sergeant, Lieutenant) and those
that are Not Supervisors (Officers).

Is there a way I can create a calculated field in a query that does
something like this ...

If the value in the member's RankName field is Sergeant or Lieutenant
return a value of "Supervisor"
If not
Return a value of "Officer"

Then can I Group By the value in this calculated field: Supervisor or
Officer?

I am not sure that this is possible or how best to go about achieving
this grouping.

Any help would be appreciated.
Thanks
John

Mar 22 '06 #2
Thanks for your response, Alllen but I wanted to avoid adding another
field to the DB.

I found a solution this morning in this forum...

Solution ...
In the Query, I added a new calculated field called JOB ...

Job: Switch([RankName] In ('Officer'),'Officers',[RankName] In
('Sergeant','Lieutenant','Inspector','Assistant
Inspector','Captain','Commander','Deputy Chief'),'Supervisors')

This "Switch" calculation created an alias for each of my two groups:
Officers and Supervisors.
My report can group on the alias.

The "Switch" expression/formula was new to me.
I found the original post in this forum.
To see it, search for Switch(

Thanks
John

Mar 22 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: hhathome | last post by:
In my report I have a calculated DateDiff Field, I also have a calculated count field. I'm trying to get a total of the DateDiff field and dividing it by the count field and I'm having problems --...
3
by: Melissa | last post by:
I have a sales report where the sales are grouped by district. The report is based on a query with criteria for sales date to get the sales in any specified date range. I have code in the Format...
3
by: kelley.l.turner | last post by:
Hi all, I am very new to MS Access so please bear with me! I have created a simple calculated field in my data entry form, yet when I view my data table or try to generate a report based on...
5
by: Henrik | last post by:
The problem is (using MS Access 2003) I am unable to retrieve long strings (255 chars) from calculated fields through a recordset. The data takes the trip in three phases: 1. A custom public...
2
by: jcf378 | last post by:
hi all. I have a form which contains a calculated control ("days") that outputs the # of days between two dates (DateDiff command between the fields and ). However, when I click "Filter by...
7
by: Sunil Korah | last post by:
Hi, I haven't used access reports much. I have a problem in getting the total of a group. I have 3 fields, ProgName (Program name), Pname (Participant's name) and PCategory (Participant...
9
by: Haas C | last post by:
Hi all! Is there anyway I can override a value in a calculated field on a form? For example: I have a form which displays the following fields based on a query: Premium Due field has the...
3
by: Matthew Wells | last post by:
If I have a calculated field that returns a value from a udf, does that field get calculated even when it's not being used in a Select statement? I knw that if a calculated field's formula is...
2
by: mkbrady | last post by:
I have a query that includes calculated fields that generate numeric results. I have wrapped conversion functions CLng() and CDdl() around the calculated fields to ensure the data types are...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.