I have a table (tblMain) with field Gender. I am trying to get a count in SQL of Female and Male personnel so I can update a form containing two fields "Male = and Female = ".
The values stored in the tbl are "M and F".
Thanks!
If you wanted ultra simple, have a tiny subform linked tothe following query: -
SELECT Sum(IIf([Gener]= "M",1,0)) AS Male, Sum(IIf([Gender] = "F",1,0)) AS Female
-
FROM tblYourTable;
-
Then the values would be updated every time..... I find having an unbound control that executes a DCount() often seems to really slow down the form.
13 4714 zmbd 5,501
Expert Mod 4TB
What have you tried so far?
Use an aggregate query grouping by the gender. If you really need the results in two different columns, use a cross tab.
zmbd 5,501
Expert Mod 4TB
ahh, rabbit... I was going to suggest that... just wanted to see what they had tried so far :)
(although I have a warm fuzzy that I was on the right track)
:)
-z
I have tried the aggregate query.
This query gives me the correct counts, but not sure how to call the count number in the report field: - SELECT tblMain.Gender, Count(tblMain.Gender) AS CountOfGender
-
FROM tblMain
-
GROUP BY tblMain.Gender;
-
The report has a txtMale & txtFemale box.
Thanks!
zmbd 5,501
Expert Mod 4TB
Are you adding the counts to a new report or an exsisting one?
* We should probabily split at this point given the question in OP appears to be answered.
hmm, do you try to seperate the 2 gender for two query? exp: select tblmain.gender count(tblmain.gender) as ... where gender = "male,m,Male" . because when you use group, i think you can show the 2 fields .
its just my advice,
zmbd 5,501
Expert Mod 4TB
lyodmichael
I wasn't very clear... if artemetis is creating a new report then simply using the query as the record source will be fairly easy to do by simply assigning the control source of the text fields to the correct query fields in the detail section of the report. The wizard actually doesn't do a bad job of creating a very simple report.
However, if artemetis is trying to add this information to an existing report then there are few hoops to jump thru to get the counts.
*This is why I have asked the thread to be re-posted as a new question as this is a seperate issue from the OP
-z
Thanks folks.
ZMBD - I'm adding this to an existin report, which contains sub-reports.
Funny thing, when creating a "New Report" when using the SQL as a datasource, I'm able to get a report showing
F - 32
M - 40
As soon as I add a subform, the subform gets displayed twice with a genderCount as a header.
(feel free to split this thread as necessary)
zmbd 5,501
Expert Mod 4TB
If you added the subform to the details section of the main form (or report) then yes, the subform will repeat for each of the grouped entries, in this case "m" and "f" so you get two... if you had "m", "f", and "h" you'd get three and so on.
If you need to get a count of the M and F to fall in the footer or header of the report there are several different ways to do that depending on how the report is bound to the record source and how it is layed out.. one way is to place a textbox in the header/footer of the form and set the control source of the text box so that you have something along the lines of - =Format(Count([ChangeToYourRSFieldName]),"Fixed")
and so forth.
-z
My main report is bound to tblMain.
This tbl has empFirstName, empLastName, empGender
I have two text boxes in the header:
txtMaleCount and txtFemaleCount
I've tried several ways to get the counts into each text box, with no success. Zmbd's last respone^^^, second paragraph, is what I'm trying to do.
Thanks, in advance.
It may be simpler if you just used unbound textboxes and set the control source to a DCount().
If you wanted ultra simple, have a tiny subform linked tothe following query: -
SELECT Sum(IIf([Gener]= "M",1,0)) AS Male, Sum(IIf([Gender] = "F",1,0)) AS Female
-
FROM tblYourTable;
-
Then the values would be updated every time..... I find having an unbound control that executes a DCount() often seems to really slow down the form.
Thanks, Twinnyfo!
That did it!!!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Kai Jaeger |
last post by:
I am playing with setting font sizes in CSS using em as unit of
measurement. All seems to be fine. Even Netscape Navigator shows the
characters very similar to IE, what is not the kind if px is...
|
by: campbellbrian2001 |
last post by:
Thanks in Advance! ... I have two textboxes: 1 is visible (and gets its
value based on the invisible textbox and displays either "Male" or
"Female", and needs to display either male of female based...
|
by: Ping |
last post by:
Hi,
I'm wondering if it is useful to extend the count() method of a list
to accept a callable object? What it does should be quite intuitive:
count the number of items that the callable returns...
|
by: Missionary2008 |
last post by:
I'm using Access 2007 with Vista. I'm trying to figure out how to write a query to take information in the fields GENDER, RETIREMENT DATE, and REGION to get a count of the number of missionaries that...
|
by: dixiebuyer |
last post by:
I have a project I am porting to the Web from stand alone Access and Word with VB. I have been pleased with LAMP so far, but this one part of the project is killing me!
Basically what I want to do...
|
by: JamesDelaney |
last post by:
Hello All,
I'm new to XSLT and XML, so please excuse the basic question. I'm trying to apply a number of conditional xsl:if statements to xsl:for-each-group, but it does not filter out the...
|
by: faefaeus |
last post by:
Hi,
I am trying to validate against gender in my code.
The function below accepts student details, part of its function is to verify that the correct lettter is enterd for gender 'm' or 'f'
It...
|
by: Bob Lee |
last post by:
Access 2010. I have a drop down list with "Male" or "Female" as the choice. I wish to count the number of Males and the number of Females to show on a report. The Field name is which is stored in a...
|
by: Swapnil Mestry |
last post by:
I want to display record in this format:
PATIENT_CODE,gender,Malecount,femalecount
Select PATIENT_CODE,gender,count(*)
From BABY_MASTER Where Patient_Code='KBB-04-2010-96'
group by...
|
by: neelsfer |
last post by:
I got this from a website for South Africa about gender and identity number: there are 13 characters in total
If 7th character (from left) of the string(ID) is between 0 and 4 the person is female,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| | |