Mark yes no in vba (1 Viewer)

ilanray

Member
Local time
Today, 10:23
Joined
Jan 3, 2023
Messages
116
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
 

cheekybuddha

AWF VIP
Local time
Today, 08:23
Joined
Jul 21, 2014
Messages
2,280
Despite the problem with the non-normalised table design, you can try:
Code:
for i = 1 to 4
  Me("team" & i) = 1
next i
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:23
Joined
May 7, 2009
Messages
19,243
if it is in the Form:

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

..ops, very slow for a small code.
 

Gasman

Enthusiastic Amateur
Local time
Today, 08:23
Joined
Sep 21, 2011
Messages
14,299
Pay attention to the non normalised comment.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 02:23
Joined
Feb 28, 2001
Messages
27,186
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

Top Bottom