Solved

Create Control and Runtime

Posted on 2004-08-23
4
333 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

761 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