Add controls based on boolean value

raystownlaura

Registered User.
Local time
Yesterday, 19:33
Joined
Apr 16, 2010
Messages
22
I want to add a text box to a form for each record in a table where [boolean]=true in a particular field in the table. I also want to assign the value in another field in the selected record to display as the label caption.

I already have written code to loop through the records in the table and find the records that will become the form controls. I need help creating a loop that will place the text boxes on the form.

For example:

If rst.boolean.value=true then
<create text box on form with rst.field2.value as label caption>
end if

I need each successive text box to place itself aligned with the previous.

If anyone can help I'd appreciate it!
 
What you are wanting to do can be done but should be avoided. Access is not a good development platform for creating forms and controls on the fly. You have to add controls to the form in design view. There are a number of headaches to doing this...still if you are bent on doing this look at the CreateControl method.
 
Thanks DJ. I appreciate your feedback. I know access isn't the best place for this, but it's really the only way I can think of without having to change the form design every time we add a new "Info Site".

Here's the scoop - we have a field that identifies a contact as a member who pays for us to distribute their brochures to info sites around the county. I need to dynamically create controls for each member where that value is "true" because it can change frequently.

The goal of the form is to create controls for each member where that field is true so that we can record the number of brochures placed at a particular site. Again, because it can change often, I need to dynamically add the text boxes each time the form opens. Make sense?

If there is a better way to do this, please feel free to suggest. I want simplicity, not a program that will be problematic.
 
If the table is designed correctly all you need is a form in continuous view.
 
That makes total sense and I feel kind of stupid for not considering that, but at the same time it's a bit complex. Then again, I tend to complicate the heck out of things that can be really simple. I'll try your suggestion and see if it works out.
 

Users who are viewing this thread

Back
Top Bottom