Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Controls

Status
Not open for further replies.

shaneh0

Programmer
Nov 4, 2002
27
US
I need to create a form with a variable number of controls.

I understand there is a CreateControl method, and that it must be used from a module on a form that is opened in Design mode.

Here's my question:

How to I dynamically name the controls?

In my module, I query for a list of questions from a given category. I loop though that list and create a different text box and label for each. How do I name these dynamically?

Also, if you have any other insight on dynamic controls, I'd love to hear it. I really wish VBA had VBs Control Array.

Thanks!!!

Shane
 
If the controls you need are all of the same type (say, textbox), then you could just put a bunch of them on a pre-designed form, and only change label and visible status on the fly (and perhaps the form height). You'd have to keep track of which is which, but that shouldn't be too difficult. If the controls are of different types, then you'll most likely need the dynamic approach.
Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top