How to clear the transaction log


This sample demonstrates how to use the IAPTransLog and IAPTransLogInfo interfaces to read and remove entries in the ArcPad transaction log.

How to use

  1. Open ArcMap.
  2. Paste the code into VBA and run the macro.
[VBA]
Public Sub ClearTransactionLog()
    On Error GoTo ErrorHandler
    '++ get a reference to the ArcPad Extension
    Dim pAPExtension As IArcPadExtension
    Dim pID As New UID
    pID = "editorExt.ArcPadExtension"
    Set pAPExtension = Application.FindExtensionByCLSID(pID)
    
    '++ get a reference to the Transaction log
    Dim pTransLog As IAPTransLog
    Dim pTransLogInfo As IAPTransLogInfo
    Set pTransLog = pAPExtension.Log
    Set pTransLogInfo = pTransLog 'QI
    
    '++ confirm the user wants to clear the log
    If (0 = pTransLogInfo.Count) Then
        MsgBox "The ArcPad transaction log is already empty.", vbInformation, "Log Empty"
        Exit Sub
    Else
        If (vbNo = MsgBox("Are you sure you want to remove the " & CStr(pTransLogInfo.Count) _
            & " entries from the ArcPad transaction log?", vbQuestion + vbYesNo, "Clear Log?")) Then
            Exit Sub
        End If
    End If
    
    While (pTransLogInfo.Count > 0)
        '++ log entry variables
        Dim sCheckoutName As String, sSrcVersion As String, sFldMapping As String
        Dim sSrcField As String, sStatusField As String
        Dim pSrcFCName As IName, pCheckoutFCName As IName
        Dim dtCheckoutDate As Variant
        
        '++ get the first entry
        Call pTransLogInfo.Entry(0, sCheckoutName, pSrcFCName, sSrcVersion, pCheckoutFCName, sFldMapping, sSrcField, sStatusField, dtCheckoutDate)
        '++ remove it from the log
        pTransLog.CheckIn pCheckoutFCName, sSrcVersion
        pTransLog.SaveLogInformation
    Wend
    
    '++ let the user know the log was cleared
    MsgBox "The ArcPad transaction log has been cleared.", vbInformation, "Log Cleared"
    Exit Sub
ErrorHandler:
    MsgBox Err.Number & vbCrLf & Err.Description & vbCrLf & Err.Source
End Sub