Charlotte Foust
cfoust at infostatsystems.com
Wed Dec 5 16:15:20 CST 2007
Why would you be setting blchk to a variant? For each works best if you
dim a control of the appropriate type and assign ctlIn to it, like this:
Dim chk As CheckBox
For Each ctlIn in Me.Controls
If ctlIn.ControlType = acCheckBox Then
chk = ctlIn
That allows you to access the nmethods and properties that belong to
that controltype, which you can't do using ctlIn.
Charlotte Foust
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Hale, Jim
Sent: Wednesday, December 05, 2007 1:31 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Loading checkbox values into an array
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-----