Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code To Change Form Control Name

Status
Not open for further replies.

GGleason

Technical User
Mar 22, 2001
321
US
Does anybody know how to change a form control name in VBA? I can find the existing name without a problem, but I don’t know how to change the name of the control. My current syntax that yields a 2467 error is:
[tt]
Me.Controls(strFrmObjNameOld).Name = strFrmObjNameNew
[/tt]
tia,
GGleason
 
You have to open the form programmatically in design view to change this kind of property, it is read only in form view. JHall
 
I do the following before trying to name it:
[tt]
DoCmd.OpenForm "Form1", acDesign
[/tt]
but I still get an error. Is there something else that needs to be done?
 
Nevermind. I got it to work!

Thanks,
GGleason
 
Where are you executing this code?


Try:
Forms!Form1.Controls(strFrmObjNameOld).Name = strFrmObjNameNew
JHall
 
As JHall indicated, my problem I was trying to alter the form I was running. The solution was to run the code from another form and it worked.

GGleason
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top