Solved

Create Control and Runtime

Posted on 2004-08-23
4
327 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now