A
Antonio via AccessMonster.com
Hi,
I'm trying to get a piece of code to wotk neat, using the Eval function, to
avoid writing a bunch of redundant code.
Note that in the code below, StrEval should always contain a double, and in
most cases the value 8. However, this way, it always returns 0...
'-----------------------------------------------------------------------------
--------------------------
Dim MyWeek: MyWeek = Array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
Dim i as Integer
(...)
For i = 0 To 6
StrEval = "TimeCardDetailRcdst![" & MyWeek(i) & "]"
If Eval(StrEval) > 0 Then 'only want to keep worked hours
ActualRcdst.AddNew
ActualRcdst![AccountGroup] = TimeCardDetailRcdst!
[AccountGroupCost]
'Instead of ActualRcdst![Hours] = TimeCardDetailRcdst![Mon]
lets try..
ActualRcdst![Hours] = Eval(StrEval)
(...)
ActualRcdst.Update
End If
Next
'-----------------------------------------------------------------------------
--------------------------
I can't seem to get Eval to execute the String like a line of code. I've also
tried to use Val and CDbl, but the value supposed to return is always 0...
Anyone?
Thanks
Antonio
I'm trying to get a piece of code to wotk neat, using the Eval function, to
avoid writing a bunch of redundant code.
Note that in the code below, StrEval should always contain a double, and in
most cases the value 8. However, this way, it always returns 0...
'-----------------------------------------------------------------------------
--------------------------
Dim MyWeek: MyWeek = Array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
Dim i as Integer
(...)
For i = 0 To 6
StrEval = "TimeCardDetailRcdst![" & MyWeek(i) & "]"
If Eval(StrEval) > 0 Then 'only want to keep worked hours
ActualRcdst.AddNew
ActualRcdst![AccountGroup] = TimeCardDetailRcdst!
[AccountGroupCost]
'Instead of ActualRcdst![Hours] = TimeCardDetailRcdst![Mon]
lets try..
ActualRcdst![Hours] = Eval(StrEval)
(...)
ActualRcdst.Update
End If
Next
'-----------------------------------------------------------------------------
--------------------------
I can't seem to get Eval to execute the String like a line of code. I've also
tried to use Val and CDbl, but the value supposed to return is always 0...
Anyone?
Thanks
Antonio