Create ADO recordset using another ADO recordset as template.
Create ADO recordset using another ADO recordset as template.
Rate Create ADO recordset using another ADO recordset as template.
(2(2 Vote))
'create an empty recordset using oRec as template
'withAttributes - fill also attributes
'withData - fill also data
If Not ExistFields(oRec) Then
GoTo Exit_Function
End If
Dim oFld As ADODB.Field, i As Integer
For Each oFld In oRec.Fields
If withAttributes Then
Call oRecDest.Fields.Append(oFld.name, oFld.Type, oFld.DefinedSize, oFld.Attributes)
Else
Call oRecDest.Fields.Append(oFld.name, oFld.Type, oFld.DefinedSize, adFldIsNullable)
End If
Next
oRecDest.Open
If withData Then
oRec.MoveFirst
Do While Not oRec.EOF
oRecDest.AddNew
For i = 0 To oRec.Fields.Count - 1
oRecDest.Fields(i).Value = oRec.Fields(i).Value
Next i
oRec.MoveNext
Loop
End If
oRecDest.Update
Exit_Function:
Call Err.Raise(Err.Number, Err.Source, Err.Description)
End Function
Create ADO recordset using another ADO recordset as template. Comments
No comments yet — be the first to post one!
Post a Comment