-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathM_omADODBFunctions.def
34 lines (29 loc) · 1.4 KB
/
M_omADODBFunctions.def
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Option Compare Database
Option Explicit
Public Function ADODBCreateCopyRecord(rsSrc As ADODB.Recordset, rsDst As ADODB.Recordset, Optional PrimaryKeyName As String = "", Optional LinkName As String = "", Optional LinkId As Long = 0, Optional ignoreFields As String) As Long
Dim fld As ADODB.Field
ADODBCreateCopyRecord = 0
rsDst.AddNew
ADODBCopyRecord rssr, rsDst, PrimaryKeyName, LinkName, LinkId, ignoreFields
If Len(PrimaryKeyName) > 0 Then
ADODBCreateCopyRecord = rsDst(PrimaryKeyName).Value
End If
End Function
Public Sub ADODBCopyRecord(rsSrc As ADODB.Recordset, rsDst As ADODB.Recordset, Optional PrimaryKeyName As String = "", Optional LinkName As String = "", Optional LinkId As Long = 0, Optional ignoreFields As String)
Dim fld As ADODB.Field
ignoreFields = PrimaryKeyName & "," & nz(ignoreFields)
For Each fld In rsSrc.Fields
If Not omStringFunctions.ContainsString(ignoreFields, fld.Name, ",") Then
If fld.Name = LinkName And LinkId <> 0 Then
rsDst(fld.Name).Value = LinkId
Else
'On Error Resume Next
If Left(fld.Name, 2) <> "s_" And fld.Type <> 204 And fld.Name <> "SSMA_TimeStamp" Then 'timestamp
rsDst(fld.Name).Value = rsSrc(fld.Name).Value
End If
'On Error GoTo 0
End If
End If
Next
rsDst.Update
End Function