checkbox value

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
 
J

JamesK

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top