ثبت اطلاعات از فرم و ساب فرم به صورت unbound
نمونه حاضر با استفاده از كد زير آماده شده :
Public Sub CopySelected(ByRef frm As Form)
Dim rs, rs1 As Recordset
Set rs = CurrentDb.OpenRecordset("form", dbOpenDynaset)
rs.AddNew
rs!ncode = Me!ncode
rs!name_family = Me!name_family
rs.Update
Set rs1 = CurrentDb.OpenRecordset("child", dbOpenDynaset)
Dim ctlSource As Control
Dim strItems, stritems2 As String
Dim intCurrentRow As Integer
Set ctlSource = frm!List6
For intCurrentRow = 0 To ctlSource.ListCount - 1
ctlSource.Selected(intCurrentRow) = True
If ctlSource.Selected(intCurrentRow) Then
rs1.AddNew
rs1!ncode = ctlSource.Column(0, intCurrentRow)
rs1!farzand = ctlSource.Column(1, intCurrentRow)
rs1!pncode = Me!ncode
rs1.Update
End If
ctlSource.Selected(intCurrentRow) = False
Next intCurrentRow
rs.Close
rs1.Close
MsgBox "data successfully saved"
End Sub