May 19 2008, 03:20 PM
Why This code Not work?
I'm just learning >> I want to add text box at runtime
Dim ctl As Control
Set ctl = CreateControl(form1, acTextBox, , "", "", "", "")
May 19 2008, 04:08 PM
I am not sure where your code is placed or the details but hope the following helps:
1. Code must not be on the form where the control is being added
2. Code format should be
Set ctltxt = CreateControl("form1", acTextBox, , , , 2000, 4000, 1000)
Where there is no parameter, it should be left blank not be (e.g.
Set ctltxt = CreateControl("form1", acTextBox, ,"" ,"" , "", "", "")
3. Form1 should be "form1" (unless form1 is a string variable and form1 = "formName")
4. You can only create a control when in design view.
Hence you will not be able to add controls in an mde database and you can't open a form in design mode if you are using MS Access Runtime.
I am not sure why you want to create a control on a form at runtime. Could you not have the control on the form with its visible property set to 'No' and then make it visible ( = Yes) when you require it?
Edited by: pere_de_chipstick on Mon May 19 17:11:21 EDT 2008.