Mark yes no in vba

ilanray

Member
Local time
Today, 14:08
Joined
Jan 3, 2023
Messages
129
Hi
I have a form with 4 boolean field (mark yes no) called team1,team2,team3,team4
is there away to mark the boxes in vba in a loop ?
for example instead of
me.team1 = 1
me.team2 = 1
me.team3 = 1
me.team4 = 1

to do something like (this is now working)

for i = 1 to 4
me.team(i) = 1
next i

Thanks
 
Despite the problem with the non-normalised table design, you can try:
Code:
for i = 1 to 4
  Me("team" & i) = 1
next i
 
if it is in the Form:

For i = 1 to 4
Me("Team" & i)=1
next

..ops, very slow for a small code.
 
Pay attention to the non normalised comment.
 
And one last thing... though it is a minor quibble, Boolean TRUE is -1, not +1. Oh, it will work OK, but for the values of TRUE and FALSE, it is -1 and 0. But I totally agree that if you have bound check boxes and the field names are xxxx1, xxxx2, etc., you have a faulty design that will come back to bite you if you aren't careful.
 

Users who are viewing this thread

Back
Top Bottom