Solved

Create Control and Runtime

Posted on 2004-08-23
4
330 Views
Last Modified: 2012-06-21
is it possible to create a control at run time? or on the click of a button is MS Access 2003? if so how?
0
Comment
Question by:Y2Kingswood
  • 2
  • 2
4 Comments
 
LVL 84
ID: 11876553
Yes, but generally speaking it's very bad idea to do this. Anytime you add controls, you run the risk (matter of fact, it's almost CERTAIN) of decompiling your application, and a decompiled application is an unstable application. Yes, you can recompile and Compact after each one of thes operations, but that requires the user to exit the application - definitely not the best of operations.

However, if you must, lookup CreateControl in online help. There's a pretty good example of how to do this.
0
 

Author Comment

by:Y2Kingswood
ID: 11876866
see the thing is i dont want to have to do this in design view all i want is for the user to say for example i need 2 textbox then 2 textbox's will apear, i could have them hidden and have a limit on how many you could have but i didnt really want to do it like that
what do you think??
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 50 total points
ID: 11876997
Yes, you can add as many controls as you think you may need and set them all .Visible=False. When the users selects the # on controls, you'd just reset to .Visible=True. If you name your controls something like ctl1, ctl2, ctl3 etc, then you can do this ina loop

Assuming you have a textbox on your form named ctlNumOfControls

dim intCount as Integer

For intCount = 1 to Me.ctlNumOfControls
  Me.Controls("ctl" & cstr(intCount)).Visible = True
next intCount

To "reset" the controls back to invisible:

For intCount = 1 to TheTotalNumberOfYourControls
  Me.Controls("ctl" & cStr(intCount).Visible = False
Next intCount

0
 

Author Comment

by:Y2Kingswood
ID: 11877019
I think that will do nicely as CreateControl seems a bit extreme.
Thanks!
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question