interesting....

FloBob

Registered User.
Local time
Yesterday, 19:20
Joined
Jul 19, 2002
Messages
108
Hey guys, I have sorta a difficult one I would like to ask if you guys have had any issues with this before.. I have a table that keeps a list of check boxes on a perticular form. What I want to have happen is call a recordset up to create a list of these objects and then test there values on the form. Let me explain a better way.

Form: ScoreCard

ChkBox 1
ChkBox 2

Table: Points

NameOfCheckBox, Points, .....

ChkBox 1 , 2 , .....
CHKBox 2 , 3 , ....


Ok now here is what im trying to do in a nutshell

*CODE**

...

Dim main as dao.recordset

Dim Total as integer


set main = currentdb.openrecordset("select * from points where
isnull(nameofcheckbox) = false")

do until main.eof

if main!nameofcheckbox = false then 'this is where im having trouble

total = total + main!points

end if

main.movenext

loop

....

*CODE*

The problem being ofcoarse that main!nameofcheckbox is translated to a text value "CheckBOX 1" instead of the pointer to the checkbox that I want it to be. Does anyone know how to make this happen? Thanks in advance for anyhelp even if its "there is no way to do this". I would like very much to be able to check every checkbox in a form without doing 500 if statements. thanks
 
Well, consider this...

If the data elements are Yes/No, then they are stored as -1 as true or 0 as false. So you could start your counts by totalling up CInt(boCheckBox) for each checkbox.

Now, as to how to do the code for the score on each record...

On a given form, you can do a programmed loop over the collection of controls on that form.

Dim ctlCur as Control
Dim loCount as Long

...

loCount = 0

For Each ctlCur in Me.Controls

If ctlCur.ControlType = acCheckBox Then
loCount = loCount - CInt( ctlCur.Value )
End If

Next ctlCur

When this is done, you have the count of "True" on all checkboxes for the current record.

If you did this with a recordset, you would use instead an iteration over all fields of type dbBoolean in the recordset.Fields collection.
 
Looping thru the conrols on the form was a beatiful Idea. It was not exactly what i needed but I was able to figure it out. Thanks so much for you help I greatly appreciate it.
 

Users who are viewing this thread

Back
Top Bottom