Solved

Create Control and Runtime

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

895 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

12 Experts available now in Live!

Get 1:1 Help Now