共用方式為


DataRecordset.GetMatchingRowsForRefreshConflict 方法 (Visio)

會傳回資料錄集資料列的資料列識別碼陣列,陣列所連結到的圖形在重新整理資料錄集之後發生衝突。

注意事項

This Visio object or member is available only to licensed users of Visio Professional 2013.

語法

運算式GetMatchingRowsForRefreshConflict (ShapeInConflict)

表達 會傳回 DataRecordset 物件的 運算式。

參數

名稱 必要/選用 資料類型 描述
ShapeInConflict 必要 圖形 連結至資料記錄集重新整理後發生衝突之資料的圖形。

傳回值

Long ()

註解

GetAllRefreshConflicts方法會傳回圖形陣列,其中圖形中的資料與圖形所連結之資料記錄集資料列中的資料之間存在衝突。 若要判斷哪些資料記錄集資料列產生衝突,您可以接著將每個圖形傳遞至 GetMatchingRowsForRefreshConflict 方法,該方法會傳回特定圖形發生衝突的資料列陣列。

當資料錄集中兩個或多個資料列有相同的主索引鍵,這些資料列可能相衝突,而且可能會連結至相同圖形。 發生這個問題時,GetMatchingRowsForRefreshConflict 會傳回至少含有兩個資料列識別碼的陣列。

從資料記錄集中移除先前的資料連結資料列時,也會發生衝突。 發生這個問題時,這個方法會傳回空的陣列。

若要移除衝突,請將衝突的圖形傳遞至 RemoveRefreshConflict 方法,這會從目前檔中移除衝突的資訊。 相關衝突資訊會保存在目前文件,直到您刪除衝突的圖形或在圖形上呼叫 RemoveRefreshConflict

範例

這個 Microsoft Visual Basic for Applications (VBA) 宏會示範如何使用 GetAllRefreshConflicts 方法來判斷哪些圖形在重新整理資料記錄集之後發生衝突,然後使用 GetMatchingRowsForRefreshConflict 方法來判斷哪些資料記錄集資料列造成衝突。 它會重新整理最近新增的資料記錄集,如果找不到任何產生的衝突,則會在 [即時運算] 視窗中列印「沒有衝突」。 如果發現衝突,它會將每個有衝突的圖形傳遞至 GetMatchingRowsForRefreshConflict 方法,並在相同的視窗中列印產生的資料列識別碼。

在執行此巨集前,請確定最近新增的資料記錄集是已連線的 (非 XML 架構) 資料記錄集,而且原始資料來源的連線仍可使用。 然後刪除資料來源中的資料列,或進行另一項變更,以在重新整理資料記錄集時造成衝突。

Public Sub GetMatchingRowsForRefreshConflict_Example() 
 
    Dim vsoDataRecordset As Visio.DataRecordset 
    Dim intRecordsetCount As Integer 
    Dim intShapeCount As Integer 
    Dim vsoShapes() As Visio.Shape 
     
    Dim intRowCount As Integer 
    Dim vsoShapeInConflict As Visio.Shape 
     
    Dim alngRowIDs() As Long 
    Dim lngvsoRowID As Long 
         
    intRecordsetCount = Visio.ActiveDocument.DataRecordsets.Count 
    Set vsoDataRecordset = Visio.ActiveDocument.DataRecordsets(intRecordsetCount) 
     
    vsoDataRecordset.Refresh 
    vsoShapes = vsoDataRecordset.GetAllRefreshConflicts 
     
    If IsEmpty(vsoShapes) Then 
        Debug.Print "No conflict" 
    Else 
        For intShapeCount = LBound(vsoShapes) To UBound(vsoShapes) 
            Set vsoShapeInConflict = vsoShapes(intShapeCount) 
            alngRowIDs = vsoDataRecordset.GetMatchingRowsForRefreshConflict(vsoShapeInConflict) 
             
            If IsEmpty(alngRowIDs) Then 
                Debug.Print "For shape:", vsoShapeInConflict.Name, "Row deleted." 
            Else 
                For intRowCount = LBound(alngRowIDs) To UBound(alngRowIDs) 
                    lngvsoRowID = alngRowIDs(intRowCount) 
                    Debug.Print "For shape:", vsoShapeInConflict.Name, "Row ID of row in conflict:", lngvsoRowID 
                Next intRowCount 
            End If 
            
        Next intShapeCount 
         
    End If 
     
End Sub

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應