Thanks guys ... At Last I did it...
The NullException is because the Field XPath Reference is not correct. And the other thing you need to catch Insert Repeating Section Operation as well. Otherwise, the event function will run twice.
Anw I'm still wondering what's the difference between Site and Source ?
Here is my code in case anyone need it
<InfoPathEventHandler(MatchPath:="/my:myFields/my:grpPointsToNote/my:rtxtPointsToNote/@my:blCompleted", EventType:=InfoPathEventType.OnAfterChange)> _
Public Sub blCompleted_attr_OnAfterChange(ByVal e As DataDOMEvent)
' Write code here to restore the global state.
If (e.IsUndoRedo) Then
Return
End If
Dim node As IXMLDOMNode
Try
If (e.Operation = "Insert") Then
Else
node= e.Site.selectSingleNode("../@my:tbAssignTo")
node.text = System.Environment.UserName
End If
Catch ex As Exception
thisXDocument.UI.Alert("ERROR")
End Try
End Sub