A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Check Boxes Sum on Forms



 
 
Thread Tools Display Modes
  #1  
Old August 31st, 2006, 01:35 PM posted to microsoft.public.access.forms
TAWise
external usenet poster
 
Posts: 39
Default Check Boxes Sum on Forms

Is there some way to show the Total of check boxes selected on a form in real
time rather than having to close the form and then re-open it?
For example,

"Klatuu" wrote:

You can loop through all the controls on your form looking for check boxes.
Use the ABS function so the -1 that represents Checked (True) will be
conterted to 1 to count the number checked. If there are any check boxes on
your form that should not be included, then you will need to add logic to
exclude that check box. The second example shows that.

Include All check boxes

Function CheckTotals() As Long
Dim lngSumTot As Long
Dim ctls As Controls
Dim ctl as Control

For Each ctl In Me.ctls
If ctl.ControlType = acCkeckbox Then
lngSumTot = lngSumTot + ABS(ctl)
End If
Next
Set ctls = Nothing
Set ctl = Nothing
CheckTotals = lngSumTot
End Functioin
------------------------------------------

Exclude A Check Box named chkDummy

Function CheckTotals() As Long
Dim lngSumTot As Long
Dim ctls As Controls
Dim ctl as Control

For Each ctl In Me.ctls
If ctl.ControlType = acCkeckbox And ctl.Name "ctlDummy" Then
lngSumTot = lngSumTot + ABS(ctl)
End If
Next
Set ctls = Nothing
Set ctl = Nothing
CheckTotals = lngSumTot
End Functioin

"TAWise" wrote:

Is there a way to count the number of "yes" selections that are made on one
form. This form contains ~50 survey-type questions regarding
skills/knowledge in a particular category (i.e., one form is "Events
Coordination". "Events Coordination has about 8 subgroups such as
"Websites", "Budget", etc. There are questions under each subgroup such as
under "Websites"...."work with web developers", design webpage", etc.
....but all of these checkmarks need to be tallied under the main category of
"Events Coordination" and they want the tally to be displayed directly on the
form and the checkmarks are clicked. I know how to =Count of a report but I
am baffled as to how to count these ~50 items immediately onto the form.
Thanx.




  #2  
Old August 31st, 2006, 01:45 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default Check Boxes Sum on Forms

Call the function in the After Update event of each check box. Add a line of
code to assign the value to the text box where you want to display the total:

CheckTotals = lngSumTot
Me.txtTotalChecked = lngSumTot
End Functioin


"TAWise" wrote:

Is there some way to show the Total of check boxes selected on a form in real
time rather than having to close the form and then re-open it?
For example,

"Klatuu" wrote:

You can loop through all the controls on your form looking for check boxes.
Use the ABS function so the -1 that represents Checked (True) will be
conterted to 1 to count the number checked. If there are any check boxes on
your form that should not be included, then you will need to add logic to
exclude that check box. The second example shows that.

Include All check boxes

Function CheckTotals() As Long
Dim lngSumTot As Long
Dim ctls As Controls
Dim ctl as Control

For Each ctl In Me.ctls
If ctl.ControlType = acCkeckbox Then
lngSumTot = lngSumTot + ABS(ctl)
End If
Next
Set ctls = Nothing
Set ctl = Nothing
CheckTotals = lngSumTot
End Functioin
------------------------------------------

Exclude A Check Box named chkDummy

Function CheckTotals() As Long
Dim lngSumTot As Long
Dim ctls As Controls
Dim ctl as Control

For Each ctl In Me.ctls
If ctl.ControlType = acCkeckbox And ctl.Name "ctlDummy" Then
lngSumTot = lngSumTot + ABS(ctl)
End If
Next
Set ctls = Nothing
Set ctl = Nothing
CheckTotals = lngSumTot
End Functioin

"TAWise" wrote:

Is there a way to count the number of "yes" selections that are made on one
form. This form contains ~50 survey-type questions regarding
skills/knowledge in a particular category (i.e., one form is "Events
Coordination". "Events Coordination has about 8 subgroups such as
"Websites", "Budget", etc. There are questions under each subgroup such as
under "Websites"...."work with web developers", design webpage", etc.
....but all of these checkmarks need to be tallied under the main category of
"Events Coordination" and they want the tally to be displayed directly on the
form and the checkmarks are clicked. I know how to =Count of a report but I
am baffled as to how to count these ~50 items immediately onto the form.
Thanx.




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:09 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.