checkbox value

  • Thread starter Thread starter dave
  • Start date Start date
D

dave

hi
i have one form and five checkbox namely chk1,chk2,chk3 and so on..
i want to check value of all checkboxes in for loop...
code snippet
for i = 1 to 5
msgbox chk&i.value
next
but its throwing error saying object required....
thanx for help
 
first you need to properly refernce them:

method 1:
Me.chk1.value
Me.chk2.value
...

method 2:
Me.Controls.Item("chk1").value
Me.Controls.Item("chk2").value
...

method 3:
Forms!myform.chk1.value
...

method 4:
Forms!myform.Controls.Item("chk1").value

ok, now, when you need to use a control refence in a for loop where their
names lend themselves to being built as incremented use either method 2 or
method 4

for i = 1 to 5
MsgBox "Control " & i & " Value: " & Me.Controls.Item("chk" & i).value,
vbOkOnly
next
 
Back
Top