Getting a checkbox name dynamically

S

Simone

Hello

I have a form that gets built dynamically so I never know that the
checkbox names will be.
Once users check a check box and click submit I need to know what
check boxes are checked and run an insert query that sets a fieldname
= values (checkboxName). I don't know how to get a check box name that
is selected ..
let's say I would like to check all check boxes checked run through my
loop and insert each ID of each check box in my table. Activecontrol
won't work since I will be clicking a button.
Any ideas

Thanks.
Simone Dupre
 
A

Adrian Jansen

If you know enough to build a form dynamically, surely you know how to loop
through the form objects collection and return just the checkboxes ?

Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
Debug.Print ctl.Name
End If
Next


Are you aware that a form can have no more that 754 objects added to it
*over its entire life* ? So so avoid a crash you have to destroy the form
and re-create it from scratch in each instance of Access.

A simpler/better way is to create enough controls on a form to suit all
forseeable needs, and just make the ones you want visible when and where you
need them.

--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
S

Simone

Hi Adrian.

There is not ctrl."name" in drop down method list.

thanks anyway.. please let me know if you have any other ideas.
 
A

Adrian Jansen

All controls have a name. Did you try the code ?

--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
S

Simone

thanks I finally got it.

Adrian Jansen said:
All controls have a name. Did you try the code ?

--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
Top