[AccessD] Eval Function... (or a better way)

Jürgen Welz jwelz at hotmail.com
Tue Jan 31 10:58:14 CST 2006


Reference the controls:

Me("Chk" & n)

or create a form reference:

Set frm = Forms("frmAnyName")
For n = 1 to 21
    frm("Chk" & n) =  bWhichWay
Next

Or create an array of controls in the form open or load

Dim chkCtl(21) As CheckBox 'at form module level scope

For n = 1 to 21
    Set chkCtl(n) = Me.("Chk" & n)
Next

Thereafter, you can reference the controls as members of the array of 
controls

For n = 1 to 21
    chkCtl(n) = bWhichWay
Next


Ciao
Jürgen Welz
Edmonton, Alberta
jwelz at hotmail.com





>From: jeff.embury at mac.com
>
>I have a form I'm constructing that has twenty one check boxes on it... 
>twenty one labels, twenty one of a lot of things... and I'm trying to alter 
>there values in a simplified way by hopefully using the Eval function - but 
>it's not working as advertised.
>
>The Scene: Microsoft Access 2003 in vba code...
>
>Check box names: Check1, Check2, Check-etc.
>
>Function to turn all check's 'on' or 'off':
>
>Function TurnMeOn(bWhichWay as boolean)
>    Dim n as integer
>    Dim s as string
>
>    n = 1
>    Do While n < 21
>       s = "form!formname.check" & trim(str(n)) & " = bWhichWay"
>       Eval (s)
>       n = n + 1
>    loop
>End Function
>
>================This doesn't' work=============== (sigh!)
>
>...if fact hardly nothing works with the Eval function as I see it...
>
>Microsoft plainly states that the Eval function can call a user defined 
>function - but if I create a function called... let's say "TESTIT()" and 
>then use Eval("TESTIT()") it pukes...
>
>
>Any help or is there a much more brilliant solution I'm unaware of?





More information about the AccessD mailing list