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

Heenan, Lambert Lambert.Heenan at AIG.com
Tue Jan 31 11:02:53 CST 2006


No need for Eval. 

If you control are *consistently* named you can try...

Function TurnMeOn(bWhichWay as boolean)
   Dim n as integer
   Dim s as string

   n = 1
   With Me
   Do While n < 21
     .Controls("Check" & n) = bWhichWay
      n = n + 1
   loop
   End With
End Function

Which eliminates he need to use the Tag property. 

Lambert

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
jeff.embury at mac.com
Sent: Tuesday, January 31, 2006 11:12 AM
To: accessD at databaseadvisors.com
Subject: [AccessD] Eval Function... (or a better way)


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?

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list