How do you dynamically create controls in an MS Access form?

I am writing a request (data entry) form in MS Access. I need to dynamically display all questions in a question table in my form labels. Each of these question labels will also be accompanied by a combo box that will display possible answers.

How can I add labels to the form dynamically?

+1


source to share


1 answer


See CreateControl Method . For the label, use the acLabel from the AcControlType enumeration as the ControlType parameter for CreateControl.

However, this will get more complicated. In addition to creating a label control, you will need to specify its title, position (Up and Left properties), and size (Width and Height properties). Possibly other properties: font name; Font size; Font weight; and etc.



It may be easier to structure the data source so that it contains a row for each question and answer pair. Then present these lines in a continuous form with two controls: a text box for the question; and a box with a list of answers. Then you don't need to dynamically create controls.

+5


source







All Articles