Unanswered: Change the name of a control using VBA?
Can anyone tell me how to change the name of a control on a form using VBA please.
I know I can use properties such as:
me.controlName.caption = "CaptionName"
but I can't use the '.name' property to change the name whilst the form is not in design mode. I have tried to do it from another form but I don't know how to reference it as I keep getting an error message.
I want to create some controls dynamically and have them sequentially named (i.e. control1, control2,...) becasue I am going to use the text & caption properties for each control in an variable array.
i.e. me(control + format$ (Intx)).text = "whatever"
The number of controls needed will vary depending on a user input in another form. I intend to open up the target form in design mode, add the controls (which is why they have to be named as such.) and then populate the text & caption properties depending on a previuos user selection.
As far as my problem is concerned I have got around it by adding a maximum number of controls and hiding what I don't need. It just would have been good to know how to add & name them through code.
You can only do it in design mode and that limits you to one user at a time. The reason is Access only allows one person to edit forms, modules, etc. at one time in versions 2000 and later.
If you don't plan on having more than one user (for example each user has their own front end) then you could probably get away with it. Me personally I would add all of the controls to the form and hide the ones I don't need. How many controls are you dealing with?