How to count a field

G

Guest

I have a field where the entry is In patient or out patient.
I want to count the number of In patients and Out patients in my report. I
can get a total of entries but can not total of in and total of out. This

="Summary for " & " 'In patients' = " & " " & [strinpatients] & " (" &
Count(*) & " " & IIf(Count(*)=1,"detail record","detail records").

is the expression I am using. Any help.
steve
 
S

Steve Schapel

Steve,

In the Control Source of an unbound textbox in the Report Footer, try it
like this...
=-Sum([YourField]="In patient")
 
G

Guest

Steve, Thanks.
I used =-Count([strIn/outpt]="yes") Where the yes is for in patients on the
report and obtain #error on the report where the sum should appear. Did i do
something wrong?
Steve J
 
S

Steve Schapel

Steve,

Is [strIn/outpt] the name of the field, and it is a text field (as
against Yes/No data type), and "yes" is the data entered to indicate an
in patient? If so, =-Sum([strIn/outpt]="yes") should give the right
result. Most likely cause of it not is if the name of the control that
you are entering this expression in is the same as the name of a field
in the report's record source.
 
G

Guest

When I used the sum function I had error of data type mismatch, so I tried
Count function, =Count([strinpt/outpt]) This gave me the total of In patients
and out patient. I would like to break this down to have total of Inpts and
outpts. Is this possible with access?
Thanks again
stevej

Steve Schapel said:
Steve,

Is [strIn/outpt] the name of the field, and it is a text field (as
against Yes/No data type), and "yes" is the data entered to indicate an
in patient? If so, =-Sum([strIn/outpt]="yes") should give the right
result. Most likely cause of it not is if the name of the control that
you are entering this expression in is the same as the name of a field
in the report's record source.

--
Steve Schapel, Microsoft Access MVP


Steve, Thanks.
I used =-Count([strIn/outpt]="yes") Where the yes is for in patients on the
report and obtain #error on the report where the sum should appear. Did i do
something wrong?
Steve J
 
S

Steve Schapel

Steve,

Yep, it's very easy. However, before I could advise specifically, I
would need to know the answers to the questions I asked in my previous
reply.
 
G

Guest

The Field is called [strIn/out Patient]. The Data type is yes/no combo box.
That is in my table. I used a tbl for my report. I am fairly new to access
and know just enough to make me dangerous.
thanks
steve j


Steve Schapel said:
Steve,

Yep, it's very easy. However, before I could advise specifically, I
would need to know the answers to the questions I asked in my previous
reply.

--
Steve Schapel, Microsoft Access MVP

When I used the sum function I had error of data type mismatch, so I tried
Count function, =Count([strinpt/outpt]) This gave me the total of In patients
and out patient. I would like to break this down to have total of Inpts and
outpts. Is this possible with access?
Thanks again
stevej
 
S

Steve Schapel

Steve,

Try it like this...
=-Sum([strIn/out Patient]=Yes)

This assumes that the data type of the [strIn/out Patient] field, as
defined in the table design, is Yes/No, and that the entry of Yes refers
to In patient.

If this doesn't work, please let us know what result you get.
 
G

Guest

strIn patientOK I looked at my table set up. th in pt and out patient field
is [strIn patient] combo box with values of 'yes' for in patient and 'no' for
outpatient.
On the report, report footer unbound box I wrote
=Count([strIn patient])="yes" This gave me a value of '0'
=Count([strIn patient]) This gave me a count of 20 that is the
total count of patients for the report.
I also tried;
=sum(IIf[strIn patient]=1,1,0) same result of 0.
I tried several differant variations. what I would like is 2 totals one of
in patient and the other of out patients. Any other suggestion?
Thanks,
steve j
 
S

Steve Schapel

Steve,

I have on a number of occasions told you to do it like this...
=-Sum([strIn/out Patient]=Yes)
Can you please tell me whether you have attempted to follow my
suggestion, and whether this produces the result you require for the
Inpatient count. Please. If not, can you please indicate why you do
not wish to follow the suggestions that have been made, nor provide the
information you are asked for.

If it does produce the result you require for the Inpatient count, then
you would get the Outpatient count by...
=-Sum([strIn/out Patient]=No)
 
G

Guest

Yes I have the result prints out is 'Yes' on the report. thats why I had
expermented with the others. Sorry I did say that before now. However it does
ask for 'enter Parameter value' prior to running the report.
steve j

Steve Schapel said:
Steve,

I have on a number of occasions told you to do it like this...
=-Sum([strIn/out Patient]=Yes)
Can you please tell me whether you have attempted to follow my
suggestion, and whether this produces the result you require for the
Inpatient count. Please. If not, can you please indicate why you do
not wish to follow the suggestions that have been made, nor provide the
information you are asked for.

If it does produce the result you require for the Inpatient count, then
you would get the Outpatient count by...
=-Sum([strIn/out Patient]=No)

--
Steve Schapel, Microsoft Access MVP


strIn patientOK I looked at my table set up. th in pt and out patient field
is [strIn patient] combo box with values of 'yes' for in patient and 'no' for
outpatient.
On the report, report footer unbound box I wrote
=Count([strIn patient])="yes" This gave me a value of '0'
=Count([strIn patient]) This gave me a count of 20 that is the
total count of patients for the report.
I also tried;
=sum(IIf[strIn patient]=1,1,0) same result of 0.
I tried several differant variations. what I would like is 2 totals one of
in patient and the other of out patients. Any other suggestion?
Thanks,
steve j
 
S

Steve Schapel

Steve,

There is something haywire here, which I am happy to try and get to the
bottom of! Can you please confirm that if you look at the design view
of your Table, the Data Type of the strIn/out Patient field is Yes/No?
Secondly, can you confirm that this expression we have been discussing
is going into the Control Source of a textbox in the Footer section of
the report? Thirdly, can you check that what you are entering is
exactly and precisely like this:
=-Sum([strIn/out Patient]=Yes)
Fourthly, can you confirm that the strIn/out Patient field is included
in the report? And finally, can you please let me know the details of
the 'enter Parameter value' prompt that you received? Thanks.
 
G

Guest

Well I think you finally did it for me. I had " " around the yes, and also
on the proprities under format I put 'yes/no'. After I fixed these and ran
the report again it works great. I owe you a beer.
Thanks a million sorry but I am a little slow.
Steve J

Steve Schapel said:
Steve,

There is something haywire here, which I am happy to try and get to the
bottom of! Can you please confirm that if you look at the design view
of your Table, the Data Type of the strIn/out Patient field is Yes/No?
Secondly, can you confirm that this expression we have been discussing
is going into the Control Source of a textbox in the Footer section of
the report? Thirdly, can you check that what you are entering is
exactly and precisely like this:
=-Sum([strIn/out Patient]=Yes)
Fourthly, can you confirm that the strIn/out Patient field is included
in the report? And finally, can you please let me know the details of
the 'enter Parameter value' prompt that you received? Thanks.

--
Steve Schapel, Microsoft Access MVP


Yes I have the result prints out is 'Yes' on the report. thats why I had
expermented with the others. Sorry I did say that before now. However it does
ask for 'enter Parameter value' prior to running the report.
steve j
 
S

Steve Schapel

Steve,

Good on you! I am very happy to know that progress has been made. Best
wishes for the rest of your work on this database.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top