Programmatically create ActiveX control on Access form
To create new control on Access form in design mode you can use CreateControl function, works fine for native controls, but for AcitveX controls (acCustomControl argument) it creates only empty container. Where can you set which control you want to create? The trick is to copy OLEData property from existing control to just created:
Dim frm As Form, ctl As ControlSet
frm = Forms("MyForm") 'Make sure it is opened in design mode Set ctl = CreateControl(frm.Name, acCustomControl, acDetail, , , 100, 100, 200, 200)
ctl.OleData = frm("cmd001").OleData 'cmd001 already exists on that form, or other opened form
ctl.Name = "cmd002"