Referencing Boolean Variable using a for loop

  • Thread starter Thread starter Alan
  • Start date Start date
A

Alan

Hopefully a simple question
I have a db than contains reference to hours worked

I am seeking to update a number of boolean variables to true using a for loop

If dtStartTime > dtEndTime Then
x = Mid(dtEndTime, 12, 2)
For i = 7 To x
Eval ("bln" & i = 1)
Next
End If

This I had hoped to update all boolean values from 7 to x to a vaule true
and then update my table however the bln7 value etc is ignored

I have tried various permutation but still stuck

Any Pointers would be appreciated
 
On Thu, 23 Jul 2009 12:26:04 -0700, Alan

You probably meant to write:
Eval ("bln" & i & "= 1")

But I for one use an Update query if I want to update values in a
table. That query may sometimes call a public function I wrote to make
some calculations.

-Tom.
Microsoft Access MVP
 
Eval("bln" & i = 1)
produces an error, try it in the immediate window:


? "aaa" & 7 = 1


And if you add " " to make it:


Eval("bln" & i & " =1" )

that is still a test, a comparison, not an assignation.


I suggest you use an array of Boolean values, or, if you want to keep alpha
references, a collection.


note that you need to add a reference to the "Microsoft Scripting Runtime"
library (Tools | References... and check the said reference) to use the
Scripting library.

====================================
Public Sub ArrayOrCollection()

Dim aaa(1 To 7) As Boolean
Dim bbb As New Scripting.Dictionary

' assign some values
aaa(4) = True
aaa(5) = False
bbb.Add "hello", True
bbb.Add "world", False

' possible uses
Debug.Print bbb("world") = aaa(5)
' using alpha reference, 'world', or
' an index value, 5

End Sub
=====================================



Vanderghast, Access MVP
 
tom

Thanks for the quick reply
I am now getting the error message

"Microsoft Access cant find the file name 'bln7' you entered in the
expression."

Still confused :(
 
Back
Top