Linking block attribute to other entity (Hatch, in your case) with field is just as simple as set the attribute's TextString to a valid field code.
For example, you can use command "Field" to find out what the field code for a Hatch's Area property is look like. In this case, if the drawing uses imperial unit, the code would look like:
%<\AcObjProp.16.2 Object(%<\_ObjId 1149432352>%).Area \f "%lu2%ps[, SQ. FT.]%ct8[0.0069444444444444]">%
As you can see, to link this field code to any Hatch object in drawing, you only need to find out the target hatch's object ID and replace it in above code. Then you simply assign this field code to AcadAttributeReference's TextString.
Following code assume that a block with name "RoomArea" has inserted into the drawing, which as a attribute with tag "Area"; and user is asked to first select a block, and then select a hatch to linked to.
Option Explicit
Public Sub SetUpField()
Dim ent As AcadEntity
Dim blk As AcadBlockReference
Dim i As Integer
Dim atts As Variant
Dim att As AcadAttributeReference
Dim hatchId As LongPtr
Dim hatchAreaFieldString As String
hatchAreaFieldString = "%<\AcObjProp.16.2 Object(%<\_ObjId [IDNUMBER]>%).Area \f ""%lu2%ps[, SQ. FT.]%ct8[0.0069444444444444]"">%"
Set ent = SelectEntity("Select RoomArea block:")
If ent Is Nothing Then Exit Sub
On Error GoTo 0
If TypeOf ent Is AcadBlockReference Then
Set blk = ent
If UCase(blk.EffectiveName) = "ROOMAREA" Then
Set ent = SelectEntity("Select room hatch:")
If ent Is Nothing Then Exit Sub
If TypeOf ent Is AcadHatch Then
hatchId = ent.ObjectID
atts = blk.GetAttributes()
For i = 0 To UBound(atts)
Set att = atts(i)
If UCase(att.TagString) = "AREA" Then
att.TextString = Replace(hatchAreaFieldString, "[IDNUMBER]", CStr(hatchId))
att.Update
Exit For
End If
Next
End If
End If
End If
End Sub
Private Function SelectEntity(msg As String) As AcadEntity
Dim ent As AcadEntity
Dim pt As Variant
On Error Resume Next
ThisDrawing.Utility.GetEntity ent, pt, vbCr & msg
Set SelectEntity = ent
End Function
While this code is used to link a existing block to room hatch, you can certainly write your own code to insert the block and create the link at the time when block is inserted.
HTH