Sum of a Check box in a Text Box

  • Thread starter Thread starter scuda11 via AccessMonster.com
  • Start date Start date
S

scuda11 via AccessMonster.com

Hi all, I have a form which is sort of a Status Board, I have a few unbound
text boxes that pull info and display totals. I am now trying to show a
number of how many times a check box has been hit for VMRS Incidents.

I am using this in my Default Value as =Sum(IIf([tblSENEIncidentLog2008.
VMRSIncident]=1,1,0))

Which is fine, but I can't get away from the negative number! How can I make
it a positive number?

Thanks!
 
Scuda,
Assuming your calculation, and the elements of that calculation are
legitimate...

=Sum(IIf(Abs([tblSENEIncidentLog2008 > VMRSIncident]) = 1, 1,0 ))

See ABS function in Help.

--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
HI Al, thanks for the response, but I am getting an #ERROR in the text box
now, no pop up error, just that one.

Al said:
Scuda,
Assuming your calculation, and the elements of that calculation are
legitimate...

=Sum(IIf(Abs([tblSENEIncidentLog2008 > VMRSIncident]) = 1, 1,0 ))

See ABS function in Help.
Hi all, I have a form which is sort of a Status Board, I have a few
unbound
[quoted text clipped - 9 lines]
 
Scuda,
Cut and Paste exactly, the code you have as the ControlSource for the
calculation.
What type of fields are VMRSIncident or tblSENEIncidentLog2008?
Are they both located on the active and open form?
What are their values when you get the #Error.

Make sure the name of the calculated field is not the same as any element
in the calculation.
Ex. Do not name the calculated field VMRSIncident or
tblSENEIncidentLog2008

Example: VMRSIncidient = 500 and VMRSIncident = 300

=Sum(IIf([tblSENEIncidentLog2008 > VMRSIncident],1 ,0 ))

will yield 1, and will add to the sum.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

scuda11 via AccessMonster.com said:
HI Al, thanks for the response, but I am getting an #ERROR in the text box
now, no pop up error, just that one.

Al said:
Scuda,
Assuming your calculation, and the elements of that calculation are
legitimate...

=Sum(IIf(Abs([tblSENEIncidentLog2008 > VMRSIncident]) = 1, 1,0 ))

See ABS function in Help.
Hi all, I have a form which is sort of a Status Board, I have a few
unbound
[quoted text clipped - 9 lines]
 
Thanks Al, the Control Source is my field VMRSIncident, which is a Yes/No
checkbox.

The record source for my form contains the table tblSENEIncidentLog2008,
which is where the VMRSIncident field lives. It is just a regular yes/no, I
have not added anything to it.

They are named differently, my Text Box to display the total is called
txtVMRSIncident.

Not sure what this means: Example: VMRSIncidient = 500 and VMRSIncident =
300

Thanks again!

Al said:
Scuda,
Cut and Paste exactly, the code you have as the ControlSource for the
calculation.
What type of fields are VMRSIncident or tblSENEIncidentLog2008?
Are they both located on the active and open form?
What are their values when you get the #Error.

Make sure the name of the calculated field is not the same as any element
in the calculation.
Ex. Do not name the calculated field VMRSIncident or
tblSENEIncidentLog2008

Example: VMRSIncidient = 500 and VMRSIncident = 300

=Sum(IIf([tblSENEIncidentLog2008 > VMRSIncident],1 ,0 ))

will yield 1, and will add to the sum.
HI Al, thanks for the response, but I am getting an #ERROR in the text box
now, no pop up error, just that one.
[quoted text clipped - 12 lines]
 
Scuda,
I'll assume your form is a Single form... not a Continuous form.

If you have a table (tblSENEIncidentLog2008), with a field in it called
VMRSIncidient (True/False), and you want to know (in a calculated field on
your form) how many records in the table have VMRSIncidient set to True...

=Abs(DSum("[VMRSIncidient]","tblSENEIncidentLog2008"))

If you had say... 20 records set to true, the DSUM would yield -20.
Adding the Abs function converts the -20 to 20.

--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."


scuda11 via AccessMonster.com said:
Thanks Al, the Control Source is my field VMRSIncident, which is a Yes/No
checkbox.

The record source for my form contains the table tblSENEIncidentLog2008,
which is where the VMRSIncident field lives. It is just a regular yes/no,
I
have not added anything to it.

They are named differently, my Text Box to display the total is called
txtVMRSIncident.

Not sure what this means: Example: VMRSIncidient = 500 and VMRSIncident
=
300

Thanks again!

Al said:
Scuda,
Cut and Paste exactly, the code you have as the ControlSource for the
calculation.
What type of fields are VMRSIncident or tblSENEIncidentLog2008?
Are they both located on the active and open form?
What are their values when you get the #Error.

Make sure the name of the calculated field is not the same as any
element
in the calculation.
Ex. Do not name the calculated field VMRSIncident or
tblSENEIncidentLog2008

Example: VMRSIncidient = 500 and VMRSIncident = 300

=Sum(IIf([tblSENEIncidentLog2008 > VMRSIncident],1 ,0 ))

will yield 1, and will add to the sum.
HI Al, thanks for the response, but I am getting an #ERROR in the text
box
now, no pop up error, just that one.
[quoted text clipped - 12 lines]
 
Hi Al, first off, thanks so much for the help, I really appreciate it.

I am still getting an error, it is a Single form. So what I did was just
start with a new unbound text box, with no control source and the code you
gave me in the Default Value. It gave me an error.

When I added the VMRSIncident as the Control Source, it gave me a -1 result.
Whats interesting is it actually displayed 0 but when I clicked on the
unbound text box in my form that relates to VMRS Incindents (I have it set up
so I can double-click a record and it takes me to the form) it THEN gives me
a -1. Unfortunately I have 3 total, I checked the table.

Frustrated! Thank you again for the help.

Al said:
Scuda,
I'll assume your form is a Single form... not a Continuous form.

If you have a table (tblSENEIncidentLog2008), with a field in it called
VMRSIncidient (True/False), and you want to know (in a calculated field on
your form) how many records in the table have VMRSIncidient set to True...

=Abs(DSum("[VMRSIncidient]","tblSENEIncidentLog2008"))

If you had say... 20 records set to true, the DSUM would yield -20.
Adding the Abs function converts the -20 to 20.
Thanks Al, the Control Source is my field VMRSIncident, which is a Yes/No
checkbox.
[quoted text clipped - 37 lines]
 
Just to expand, I have a few other text boxes just like it on the form such
as:
DSum("[LIVESASSISTED]","tblSENEIncidentLog2008")

Which gives me the total Lives Saved entered on that form, but it is a text
box, this is the first yes/no box I have tried.


Hi Al, first off, thanks so much for the help, I really appreciate it.

I am still getting an error, it is a Single form. So what I did was just
start with a new unbound text box, with no control source and the code you
gave me in the Default Value. It gave me an error.

When I added the VMRSIncident as the Control Source, it gave me a -1 result.
Whats interesting is it actually displayed 0 but when I clicked on the
unbound text box in my form that relates to VMRS Incindents (I have it set up
so I can double-click a record and it takes me to the form) it THEN gives me
a -1. Unfortunately I have 3 total, I checked the table.

Frustrated! Thank you again for the help.
Scuda,
I'll assume your form is a Single form... not a Continuous form.
[quoted text clipped - 13 lines]
 
Al, I got it! I had the code in default value, I placed it in the control
source and voila!

Thanks again so much for the help!
Just to expand, I have a few other text boxes just like it on the form such
as:
DSum("[LIVESASSISTED]","tblSENEIncidentLog2008")

Which gives me the total Lives Saved entered on that form, but it is a text
box, this is the first yes/no box I have tried.
Hi Al, first off, thanks so much for the help, I really appreciate it.
[quoted text clipped - 15 lines]
 
Scuda,
Good deal. That's the way to hang in there an give it some "sweat
equity."

In my second post...
Scuda,
Cut and Paste exactly, the code you have as the ControlSource for the
calculation.

There would have been no way for me to know that you were using
DefaultValue instead of the ControlSource.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."


scuda11 via AccessMonster.com said:
Al, I got it! I had the code in default value, I placed it in the control
source and voila!

Thanks again so much for the help!
Just to expand, I have a few other text boxes just like it on the form
such
as:
DSum("[LIVESASSISTED]","tblSENEIncidentLog2008")

Which gives me the total Lives Saved entered on that form, but it is a
text
box, this is the first yes/no box I have tried.
Hi Al, first off, thanks so much for the help, I really appreciate it.
[quoted text clipped - 15 lines]
 
So true, I never said it so how would you know it?

Thanks again!

Al said:
Scuda,
Good deal. That's the way to hang in there an give it some "sweat
equity."

In my second post...
Scuda,
Cut and Paste exactly, the code you have as the ControlSource for the
calculation.

There would have been no way for me to know that you were using
DefaultValue instead of the ControlSource.
Al, I got it! I had the code in default value, I placed it in the control
source and voila!
[quoted text clipped - 15 lines]
 
Back
Top