|
可以用CreateControl 方法,但是只能在mdb中用,MDE不能用,以下是帮助里的示例:示例下面的示例首先基于“订单”表创建一个新窗体,然后使用 CreateControl 方法在窗体上创建文本框控件和附属标签控件。- Sub NewControls() Dim frm As Form Dim ctlLabel As Control, ctlText As Control Dim intDataX As Integer, intDataY As Integer Dim intLabelX As Integer, intLabelY As Integer ' Create new form with Orders table as its record source. Set frm = CreateForm frm.RecordSource = "Orders" ' Set positioning values for new controls. intLabelX = 100 intLabelY = 100 intDataX = 1000 intDataY = 100 ' Create unbound default-size text box in detail section. Set ctlText = [b]CreateControl([/b]frm.Name, acTextBox, , "", "", _ intDataX, intDataY[b])[/b] ' Create child label control for text box. Set ctlLabel = [b]CreateControl([/b]frm.Name, acLabel, , _ ctlText.Name, "NewLabel", intLabelX, intLabelY[b])[/b] ' Restore form. DoCmd.RestoreEnd Sub
复制代码 |
|