I am using the code below to create invoices for entities that are part of a group

the whole process is complicated, as it creates many invoices in the same document
then adds a summary from another template afterwards - but all that works fine

For various reasons, the users need to do it in word, so simple access reports are not the solution.

It all works, except for one issue
I am having issues where the code below is commented with this:

'*****adds data to columns above - then inserts a row - then loops thru till end of recordset

here's what happens....

after each line item - it inserts a blank row - then loops thru the recordset adding invoice line items
it all works fine - except for the fact that it adds a blank line after the last line item
this messes up a formula field in word where it uses the Sum(Above) function
I have to manually delete the last blank line and update the field to make it calculate

I would like it to add each line item, then a blank row - except I do not want to add a blank line after the last line item entry - or somehow - delete the last blank line in code

for now - after the word doc is generated - I delete the extra row - update the field and all is well
so we are able to use it, but not without some fussing....

if I knew how to access the very last cell in the table in code - I could move up 5 rows
then select the row and delete it - then update the field and it would all work...

or maybe there are other ways????

the table in word looks like this:

header row
blank line
line item - code below inserts a blank row then loops
line item - code below inserts a blank row then loops
line item - code below inserts a blank row then loops
line item - code below inserts a blank row then loops
blank line - ****this line messes it up - if I delete this manually and update the total field - it works fine
service fee - a service fee entry on all invoices
blank line
blank line
total (formula field to sum above)

--- entire code below ----------------------------------------------

Private Sub CreateFormLetter(WordObj As Word.Application)

Dim db As Database
Dim rsEntitiesJurisdictions As New ADODB.Recordset
Dim rsEntitiesSubTotal As New ADODB.Recordset
Set db = CurrentDb()
Dim ID, Criteria
Dim objTable As Table
Dim objTableB As Table
Dim intNumRows As Integer
Dim i As Integer
Dim j As Integer

With WordObj
.Visible = True

Dim strSQLEntitiesJurisdictions As String

strSQLEntitiesJurisdictions = "SELECT * from qryAnnualFilings_Entities_Jurisdictions WHERE (((qryAnnualFilings_Entities_Jurisdictions.EntityC ode)=" & "'" & Me.EntityCode & "'))"
rsEntitiesJurisdictions.Open strSQLEntitiesJurisdictions, CurrentProject.Connection, adOpenKeyset, adLockOptimistic


Dim strSQLEntitiesSubTotal As String

strSQLEntitiesSubTotal = "SELECT * from qryAnnualFilings_Entities_SubTotal WHERE (((qryAnnualFilings_Entities_SubTotal.EntityCode)= " & "'" & Me.EntityCode & "'))"
rsEntitiesSubTotal.Open strSQLEntitiesSubTotal, CurrentProject.Connection, adOpenKeyset, adLockOptimistic


.Selection.TypeText Text:=Format(Me.AnnualMinutesFee, "#,##0.00")

Set objTable = .ActiveDocument.Tables((currentNdx - 1) * 2 + 1)
Set objTableB = .ActiveDocument.Tables(currentNdx * 2)

i = 2

Do While Not rsEntitiesJurisdictions.EOF

i = i + 1

'add groupname

objTable.Cell(6, 1).Range.Text = Me.GroupName

'add invoice number
objTable.Cell(9, 3).Range.Text = "CS-09-" & Me.txtGroup & "-" & Me.EntityCode
objTable.Cell(11, 1).Range.Text = Me.EntityName

objTableB.Cell(i, 1).Range.Text = rsEntitiesJurisdictions("Jurisdiction")
objTableB.Cell(i, 3).Range.Text = Format(rsEntitiesJurisdictions("FilingFee"), "#,##0.00")
objTableB.Cell(i, 5).Range.Text = Format(rsEntitiesJurisdictions("AgentFee"), "#,##0.00")

If Format(rsEntitiesJurisdictions("FilingFee"), "#,##0.00") = 0 Then

objTableB.Cell(i, 7).Range.Text = Format(0, "#,##0.00")


objTableB.Cell(i, 7).Range.Text = Format(Me.CSCRepresentationFee, "#,##0.00")

End If

objTableB.Cell(i, 9).Range.Text = Format(rsEntitiesJurisdictions("LineTotal"), "#,##0.00")

'*****adds data to columns above - then inserts a row - then loops thru till end of recordset

If Not rsEntitiesJurisdictions.EOF Then

objTableB.Cell(i, 3).Select
.Selection.InsertRowsBelow NumRows:=1

End If



If Me.CurrentRecord < Me.Recordset.RecordCount Then

'insert another document from the template for the next entity

.Selection.GoTo What:=wdGoToLine, Which:=WdGoToDirection.wdGoToLast
.Selection.InsertBreak Type:=wdPageBreak
.Selection.InsertFile FileName:=strDocAdd
End If

' Clean up.
Set objTable = Nothing
Set objTableB = Nothing

End With


End Sub