T
Tom
Hello Experts,
I have a form that contains 7 checkboxes. All of the checkboxes cover the
"same subject". Currently, all of them are linked to their own field in a
table.
I want to come up w/ a "smart way" (modify table/form) so that I only have
one field that stores any combination of the up to 7 values.
So, instead of having fields
Check1, Check2, Check3, ..., Check7 with values
[True], [False], [False], ..., [True]
I want to have a single field like e.g. "CheckAll" that stores a FieldId
(e.g. [1], [2], [3], [4], [5], [6], [7]) such as 1,2,3,7
I have done some research and came up the "concept" of using a binary
field... Unfortunatly, I'm unable to integrate this method into my form...
specifically as it relates to saving the on/off values of the 7 checkboxes
into a single field.
Again, here's what I found:
Using the binary process, I'd store any combination of the 7
checked/unchecked checkboxes. For instance:
Check is on 1, 2, 4, 7 -- binary value equals "1001011"
Check is on only 5 -- binary value equals "0010000"
Check is on 1, 6 -- binary value equals "0100001"
I then came across the function below....
&&&&&&&&&&&&&&&&&
Dim i As Long
Dim SecondaryTOA As Integer
For i = 0 To 6
If Me.Controls("Check" & (i + 1)) Then
SecondaryTOA = SecondaryTOA Or 2 ^ i
End If
Next
&&&&&&&&&&&&&&&&&
Now, here's what I have in my testing db:
- Table with field "SecondaryTOA" (Integer)
- Form with 7 checkboxes... their control names are Check1, Check2, Check3,
..... Check7
- Currently, the 7 checkboxes are unbound
If I can simply plug in this For loop into my form, how do I modify my
checkboxes? More specifcally,
- do the 7 checkboxes remain "unbound"?
- do I need to use 7 individual "AfterUpdate" events?, or
- do I plug this function into the OnCurrent event? Currently, I'm getting
an error = "Invalid use of Null"
- if the above won't work for this approach, what other method could I use
to get this to work?
Tom
P.S. I posted a sample file at:
http://www.savefile.com/files.php?fid=1831514
I have a form that contains 7 checkboxes. All of the checkboxes cover the
"same subject". Currently, all of them are linked to their own field in a
table.
I want to come up w/ a "smart way" (modify table/form) so that I only have
one field that stores any combination of the up to 7 values.
So, instead of having fields
Check1, Check2, Check3, ..., Check7 with values
[True], [False], [False], ..., [True]
I want to have a single field like e.g. "CheckAll" that stores a FieldId
(e.g. [1], [2], [3], [4], [5], [6], [7]) such as 1,2,3,7
I have done some research and came up the "concept" of using a binary
field... Unfortunatly, I'm unable to integrate this method into my form...
specifically as it relates to saving the on/off values of the 7 checkboxes
into a single field.
Again, here's what I found:
Using the binary process, I'd store any combination of the 7
checked/unchecked checkboxes. For instance:
Check is on 1, 2, 4, 7 -- binary value equals "1001011"
Check is on only 5 -- binary value equals "0010000"
Check is on 1, 6 -- binary value equals "0100001"
I then came across the function below....
&&&&&&&&&&&&&&&&&
Dim i As Long
Dim SecondaryTOA As Integer
For i = 0 To 6
If Me.Controls("Check" & (i + 1)) Then
SecondaryTOA = SecondaryTOA Or 2 ^ i
End If
Next
&&&&&&&&&&&&&&&&&
Now, here's what I have in my testing db:
- Table with field "SecondaryTOA" (Integer)
- Form with 7 checkboxes... their control names are Check1, Check2, Check3,
..... Check7
- Currently, the 7 checkboxes are unbound
If I can simply plug in this For loop into my form, how do I modify my
checkboxes? More specifcally,
- do the 7 checkboxes remain "unbound"?
- do I need to use 7 individual "AfterUpdate" events?, or
- do I plug this function into the OnCurrent event? Currently, I'm getting
an error = "Invalid use of Null"
- if the above won't work for this approach, what other method could I use
to get this to work?
Tom
P.S. I posted a sample file at:
http://www.savefile.com/files.php?fid=1831514