Dynamically add/remove text boxes on form. (1 Viewer)

haydenal

Registered User.
Local time
Today, 13:36
Joined
Jan 8, 2009
Messages
52
I'm not sure how exactly to ask this, but here goes...

I have a data entry form that I would like to populate with text boxes based on information from a table. Basically if there is a value in the field in the table I would like to add text box to a form, if no value don't add a text box. So for example, if record 1 in the table has 10 fields with 2 of the 10 fields having a value, I'd get 2 text boxes on the form.

Any suggestions?
 

MSAccessRookie

AWF VIP
Local time
Today, 14:36
Joined
May 2, 2008
Messages
3,428
I'm not sure how exactly to ask this, but here goes...

I have a data entry form that I would like to populate with text boxes based on information from a table. Basically if there is a value in the field in the table I would like to add text box to a form, if no value don't add a text box. So for example, if record 1 in the table has 10 fields with 2 of the 10 fields having a value, I'd get 2 text boxes on the form.

Any suggestions?



I am not sure you can do that, and even if you can, adding and subtracting things from a form creates a lot of overhead. Consider adding and hiding the total amount of fields that you will need (10?) and then displaying only the ones that you need/want to use. That is much easier, and can be controlled via VB Coding.
  • You can start with all Controls invisible.
  • Whenever a Control is being used, it can be made Visible in order to show the value.
 

missinglinq

AWF VIP
Local time
Today, 14:36
Joined
Jun 20, 2003
Messages
6,420
Simply put, don't do it! Adding controls dynamically is going to render you form unusable in very short order.

A form has a limit of 755 controls over the lifetime of the form. In other words, if you add 10 textboxes, 75 times, you cannot add any more, and trying to do so will pop an error. Access counts all controls towards this limit, including ones that are subsequently deleted.

This kind of thing needs to be done, assuming this is a Single View Form, by using the Form_Current event and only showing the textboxes is they contain data.
 

Users who are viewing this thread

Top Bottom