Private Sub Command4_Click()
Dim frm1 As Form
Dim ctls1 As Controls
Dim ctl1 As Control
Dim frm2 As Form
Dim ctls2 As Controls
Dim i As Long, j As Long
Set frm1 = Me.条件查询入库明细子窗体.Form
Set ctls1 = frm1.Controls
Set frm2 = Forms("出库主窗体").Controls("F_ProIn2").Form
Set ctls2 = frm2.Controls
For i = 1 To frm1.RecordsetClone.RecordCount
frm1.SelTop = i
If ctls1("P_Select") = True Then
Forms("出库主窗体").Form.SetFocus
Forms("出库主窗体").Controls("F_ProIn2").SetFocus
If Nz(ctls2("P_ID").Value, 0) <> 0 Then
DoCmd.RunCommand acCmdRecordsGoToNew
End If
For Each ctl1 In ctls1
If ctl1.ControlType <> acLabel Then
If ctlEx(frm2, ctl1.Name) = True Then
ctls2(ctl1.Name).Value = ctl1.Value
End If
End If
Next ctl1
End If
Next
frm1.Requery
frm2.Requery
End Sub
Function ctlEx(frm As Form, ctlname As String) As Boolean
Dim ctls As Controls
Dim ctl As Control
Set ctls = frm.Controls
ctlEx = False
For Each ctl In ctls
If ctl.Name = ctlname Then
ctlEx = True
Exit For
End If
Next ctl
End Function