Private Function updateExternalDB(ByVal auditId As String, ByVal externalDB As adoUtil, ByVal tablename As String, ByVal key As String, ByVal oldKey As String) As String
On Error Resume Next
Dim errorStr As String
Dim searchKey As String
Dim parentRS As Object
' gDBUtility is declared as Global and .getParentRSA routine Successfully retrieves field Data from Parent Database Table
' This is carried out after the Parent Table has Successfully been updated with Empty Values for relevant dates.
Set parentRS = gDBUtility.getParentRSA("select " & gDBUtility.getMyTableExportFields & " from myTable where cardnumber = " & key)
If Not parentRS Is Nothing Then
If parentRS.EOF = False Then
If errorStr = "" Then
Dim externalparentRS As Object
Set externalparentRS = externalDB.getParentRSA("select * from " & tablename & " where cardnumber = " & key, True)
If externalparentRS Is Nothing Then
Set externalparentRS = externalDB.getParentRSA(tablename, True, , True)
externalparentRS.addNew
Else
If externalparentRS.EOF Then
externalparentRS.addNew
End If
End If
Dim f As adoDB.field
Dim fieldname As String
For Each f In parentRS.fields
fieldname = f.name
If Not IsNull(parentRS.fields(fieldname)) Then
If parentRS.fields(fieldname) <> "" Then
' This line below is where the NULL date value is passed and never inputs at externalparentRS.Update
externalparentRS.fields(fieldname) = parentRS.fields(fieldname)
If err.Number <> 0 Then
'Debug.Print "Failed: " & err.description
End If
End If
End If
Next
externalparentRS.Update
If err.Number <> 0 Then
updateExternalDB = err.description
End If
Else
updateExternalDB = errorStr
End If
End If
End If
parentRS.Close
Set parentRS = Nothing
End Function
|