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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|