[AccessD] Loading checkbox values into an array

Hale, Jim Jim.Hale at FleetPride.com
Wed Dec 5 15:30:42 CST 2007


OK, the following function correctly identifies the checkboxes and their
values (-1 or 0) but for some reason
blChk(intIndex) = ctlIn.Value isn't working. No error, blchk is just
wrong (always false). 
blChk(intIndex) = cbool(ctlIn.Value) doesn't work either or setting
blchk to a variant.
What am I missing? TIA
Jim Hale

 Function LoadArray()
Dim ctlIn As Control, intIndex As Integer

Dim blChk(0 To 13) As Boolean

    For Each ctlIn In Me.Controls
    If ctlIn.ControlType = acCheckBox Then
       
       blChk(intIndex) = ctlIn.Value
        intIndex = intIndex + 1
     MsgBox ctlIn.ControlType & " " & intIndex & " " & ctlIn.Value
    End If
     
    Next ctlIn
    
End Function

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Tuesday, December 04, 2007 6:39 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Loading checkbox values into an array

Give us a little more info.  Why do you need to load into an array?  An
array of what?

(air code)

function LoadArray (ParamArray varCtls() as variant)	
dim ctl as control
dim Arr(13) as variant
dim intIndex as integer
	for each ctl in varCtls
		arr(intIndex) = ctl.value
		intindex+=1
	next ctl 
	LoadArray = Arr
end function

?LoadArray(Chk1, Chk2, Chk3 etc etc)(0)

returns an array and displays the 0th element

Something like that?

You really should do some error checking to see how many objects varCtls
contains in case you pass in 14 controls (you'd get a runtime error).

John W. Colby
Colby Consulting
www.ColbyConsulting.com 
-----Original Message-----

***********************************************************************
The information transmitted is intended solely for the individual or
entity to which it is addressed and may contain confidential and/or
privileged material. Any review, retransmission, dissemination or
other use of or taking action in reliance upon this information by
persons or entities other than the intended recipient is prohibited.
If you have received this email in error please contact the sender and
delete the material from any computer. As a recipient of this email,
you are responsible for screening its contents and the contents of any
attachments for the presence of viruses. No liability is accepted for
any damages caused by any virus transmitted by this email.




More information about the AccessD mailing list