The following example opens a document from a read/write folder using the Internet Publishing Provider. The Status property of a Field object of the Record will first be set to adFieldPendingInsert, then be updated to adFieldOk.
sub insert()
Dim rec As New Record
' Open a read/write document
rec.Open "http://websrv/folder/subfolder", , adModeReadWrite, _
adCreateCollection Or adOpenIfExists
Debug.print "Append couple of fields"
rec.Fields.Append "chektest:fld1", adWChar, 42, adFldUpdatable, "fld1"
rec.Fields.Append "chektest:fld2", adWChar, 42, adFldUpdatable, "fld2"
Debug.Print "status for the fields"
Debug.Print rec.Fields("chektest:fld1").Status 'adfldpendinginsert
Debug.Print rec.Fields("chektest:fld2").Status 'adfldpendinginsert
rec.Fields.Update
debug.print "Update succeeds"
Debug.Print rec.Fields("chektest:fld1").Status
' adFieldOK if the update succeeds
Debug.Print rec.Fields("chektest:fld2").Status
' adFieldOK if succeeds
End sub
The following example deletes a known Field from a Record opened from a document. The Status property will first be set to adFieldOK, then adFieldPendingUnknown.
sub delete()
Dim rec As New Record
Dim fld As Field
' Open a read/write document
rec.Open "http://websrv/folder/subfolder", , adModeReadWrite, _
adCreateCollection Or adOpenIfExists
Debug.Print rec.Fields("chektest:fld1").status ‘ should be adFldOK
' Delete a field which already exists in the collection
rec.Fields.Delete "chektest:fld1"
Set fld = rec.Fields("chektest:fld1")
Debug.Print rec.Fields("chektest:fld1").Status ' Pending delete
rec.Fields.Update
Debug.Print "Deleted"
Debug.Print fld.Status ' Pending unknown
End sub
The following code deletes a Field from a Record opened on a read-only document. Status will be set to adFieldPendingDelete. At Update, the delete will fail and Status will be adFieldPendingDelete plus adFieldPermissionDenied. CancelUpdate clears the pending Status setting.
sub delete2()
Dim rec As New Record
Dim fld As Field
' Open a read/write document
rec.Open "http://websrv/folder/subfolder", , adModeReadWrite, _
adCreateCollection Or adOpenIfExists
Debug.Print "Try to delete something without permission"
rec.Fields.Delete ("RESOURCE_PARSENAME")
Set fld = rec.Fields("RESOURCE_PARSENAME")
Debug.Print "Pending delete"
Debug.Print fld.Status ' Pending delete
Debug.Print "Delete should fail on Update"
rec.Fields.Update ' Should fail
Debug.Print fld.Status ' Pending delete plus error
rec.Fields.CancelUpdate
Debug.Print fld.Status ' Okay
End sub