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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating controls at runtime...in need of some advice!

Status
Not open for further replies.

tictac1101

Programmer
Jan 26, 2007
4
GB
Is it possible to create multiple text box controls on runtime in Access 97/2003?

The reason for this, is because the controls dimensions/values need to be set using data from a recordset. Because I don't know how many controls will end up being on the form, I can't simply use the hide/unhide method.

Ideally I would like to create them on a button_click event within the active form, but I am open to suggestions!

Thanks in advance... :)

Matt
 
this can be don easily.
See create control method but be aware that the form must be in designview to add the controls
 
Thanks for your reply gol4.

I am aware of this function, but as you said it needs to run in design view.

Unless there is a way to switch from design view to form view using vb, then this would only be usefull for creating wizards etc?

I think I might have to create a heap of invisible text boxes on the form and use them when needed (a little messy!), unless anyone has another idea?
 

I've seen this routine somewhere recently but haven't really tested it myself. It requires clicking on a button on FormA that opens FormB, then closes FormA. Then in the Form_Load event of FormB

1) docmd.openform "FormA", acdesign

2) Do whatever you need to do to FormA in Design View

3) Re-open FormA

4) Close FormB

Seems like a lot of work! How many variations do you anticipate,i.e. will it be either 2, 4, 6, 9 or 12 controls,
or are there a myriad of possibilities?

Good luck!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Also, remember you can open forms in design view, but hidden, so you don't see windows popping open and shutting.

Ken S.
 
How are ya tictac1101 . . .
[blue]I can't simply use the hide/unhide method.[/blue]
. . . and whats preventing you from using this?



Calvin.gif
See Ya! . . . . . .
 
Thanks for your replies... I ended up creating 100 small invisible text boxes on my form and going with the set visible = true method.

Using the controls index number I am able to set the x,y coordinate, width, etc depending on the value in a combo box.

A little messy but it works perfectly!

Cheers, Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top