Reputation: 3
I'm trying to create a form in MS Access where based on value we enter in a text box, that many text boxes will be created automatically. For ex, if value 3 is entered, three text boxes must be created.
Part of Code:
Dim box As Control
Set box = CreateControl("Form1", acTextBox)
But I get run time error "You must be in Design or Layout View to create or delete controls"
Is is not possible to dynamically create text boxes in MS Access. If we can, please suggest how to do. Thank you
Upvotes: 0
Views: 317
Reputation: 4099
Instead of creating controls on the form based on a user entered requirement, you would normally have created as many controls as are needed beforehand (possibly positioning them correctly, and setting the tab order etc.), and then set their .Visible
and .Enabled
properties as required.
However, this is one of those instances where it may be that you are not using Access properly - any time that something is hard or difficult to do often means that you are not using it in the manner intended.
Regards,
Upvotes: 2