这个事情很简单嘛,你在主窗体上建一个按钮,然后写如下代码:
Private Sub 复制_Click()
Dim ctls As Controls
Dim ctl As Control
Set ctls = Me.sub0.Form.Controls
For Each ctl In ctls
If ctl.ControlType <> acLabel Then
If ctl.Name <> "编号" Then
Me.Controls(ctl.Name).Value = ctl.Value
End If
End If
Next ctl
End Sub
如果想用子窗体某字段的双击事件,则可以:
Dim ctls As Controls
Dim ctl As Control
Set ctls = Me.Controls
For Each ctl In ctls
If ctl.ControlType <> acLabel Then
If ctl.Name <> "编号" Then
Me.Parent.Form.Controls(ctl.Name).Value = ctl.Value
End If
End If
Next ctl
如果想对子窗体所有控件的双击事件均加载复制功能,则可以:
Function AllDblClick()
Dim ctls As Controls
Dim ctl As Control
Set ctls = Me.Controls
For Each ctl In ctls
If ctl.ControlType <> acLabel Then
If ctl.Name <> "编号" Then
Me.Parent.Form.Controls(ctl.Name).Value = ctl.Value
End If
End If
Next ctl
Me.Parent.Form.Requery
Me.Requery
Me.Parent.SetFocus
DoCmd.RunCommand acCmdRecordsGoToNew
End Function
Private Sub Form_Load()
Dim ctls As Controls
Dim ctl As Control
Set ctls = Me.Controls
For Each ctl In ctls
If ctl.ControlType <> acLabel Then
ctl.OnDblClick = "=AllDblClick()"
End If
Next ctl
End Sub