total number of checkboxes checked, Access form

V

veggiedi

Hi,

I'm having major difficulties getting what would conceptually seem
like a simple bit of programming, working!

I'm working with an Access form where, in real time, a researcher will
observing a session, noting if specific activities occur across 12
five-minute time periods. For each time period, (act1_t1, act_1t2,
act1_t3, etc) there is a check box where, if the activity occurs, the
check box will be checked; if the activity doesn't occur, the check
box will be left blank.

I have gotten some code working with a command button that will
calculate a running total on the number of check boxes checked in a
total field (act1_total) -- the big problem is, this total is not
stored in the table that the form is created from!

What I ultimately need is a field, for each activity, on each
individual record, that gives me the total number of boxes checked
from act1_t1 through act1_t12 (activity #1, time periods one through
tweleve) and then again for each subsequent activity and its time
periods on the record. I also need this total to be retained in the
data table so that the data can be exported and analyzed.

Thank you in advance for any help you may be able to offer!!
-diane

-- Here's the code I have that uses a command button to sum the total
number of boxes checked, but unfortunately doesn't retain that total
in the datatable:

Option Compare Database

Private Sub Command30_Click()

Dim RunningTotal As Double

RunningTotal = 0

If Me.focus_t1.Value = True Then
RunningTotal = RunningTotal + 1
End If

If Me.focus_t2.Value = True Then
RunningTotal = RunningTotal + 1
End If

If Me.focus_t3.Value = True Then
RunningTotal = RunningTotal + 1
End If

Me.focus_tot = RunningTotal


End Sub


Private Sub focus_tot_Click()

End Sub
 
M

Maverick

Although I'm not an expert, I can give you my 2 cents worth. First, most
Access folk would say that if you can calculate the results, it doesn't need
to be stored in the database.

If you truly feel that the calculation isn't good enough, you could send the
value of the total directly to the table. Try the following:

DoCmd.RunSQL "Insert Into YourTableName
(NameOfFieldInTableWhereYouWishToStoreTotal) " & "Values (Me.act1_total)"
 

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