access can't add, rename or delete controls you requested

T

tzigone

hi
i am trying to add textboxes to form via vba.
i am firstly closing the form and then open it in design form, then
trying to add textbox. hovewever runtime error 29054 occurs and says
access can't add, rename or delete controls you requested.
what should i do?
code is like this

DoCmd.Close

DoCmd.OpenForm "Form1", acDesign, , , acFormEdit, acWindowNormal

Dim ctl As Control
Set ctl = CreateControl("Form1", acTextBox, acDetail)
 
W

William Taylor

You have to add the control to the controls collection. set a variable for
the form and the controls collection, then use the add method to add it to
the collection.
 
T

tzigone

thank you. i don't know to make a collection. does this collection b
forms' corol collection?
dim frm as form
dim ctl as control
frm=me
frm.controls.add ctl
set ctl =createcontrol(frm,....)
is this correct
 
T

TC

Is that the >running< form?

A running form can not change its own design - even by closing itself & then
reopening itself in Design view. Your only option is to pre-allocate a
suitable number of controls, set them invisible at design time, then change
the propeties at runtime to make them appear as required.

HTH,
TC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top