L
Linda
I thought that this was pretty straightforward code but I cannot get
off of row one.
When I execute this bit I end up with a table with one row of data and
it is the last row from the dataset pulled. It overwrites the header
row and every other recordset of information that the SQL statement
pulls. If I take the loop out, I get just the first row of data as you
would expect. There are no errors. Just poor results LOL.
Can someone spot why I am not getting additional rows? There should be
4 including the header.
With vRecordSet
If Not .EOF Then
.MoveFirst
rowcount = 1
Set objTable = ActiveDocument.Tables(1)
objTable.Cell(rowcount, 1).Range.Text = "Resolution #"
objTable.Cell(rowcount, 2).Range.Text = "Topic"
objTable.Cell(rowcount, 3).Range.Text = "Department"
Do While Not .EOF
rowcount = rowcount + 1
vResolutionNumber = vRecordSet("resolutionNumber")
vTopic = vRecordSet("topic")
vDepartment = vRecordSet("department")
objTable.Cell(rowcount, 1).Range.Text =
vResolutionNumber
objTable.Cell(rowcount, 2).Range.Text = vTopic
objTable.Cell(rowcount, 3).Range.Text = vDepartment
'Go to next record, exit after last
vRecordSet.MoveNext
Loop
Set objTable = Nothing
Else
'if you ARE *else* (are .EOF), that means no record was
matched, tell the user
MsgBox "No possible match was found."
End If
End With
********************************************************
I have tried a number of ways to insert rows but the following code
which seems like it should work, claims that part or all of the 2nd
line is not in reference to a table.
objTable.Rows(rowcount).Select
Selection.InsertRowsBelow
off of row one.
When I execute this bit I end up with a table with one row of data and
it is the last row from the dataset pulled. It overwrites the header
row and every other recordset of information that the SQL statement
pulls. If I take the loop out, I get just the first row of data as you
would expect. There are no errors. Just poor results LOL.
Can someone spot why I am not getting additional rows? There should be
4 including the header.
With vRecordSet
If Not .EOF Then
.MoveFirst
rowcount = 1
Set objTable = ActiveDocument.Tables(1)
objTable.Cell(rowcount, 1).Range.Text = "Resolution #"
objTable.Cell(rowcount, 2).Range.Text = "Topic"
objTable.Cell(rowcount, 3).Range.Text = "Department"
Do While Not .EOF
rowcount = rowcount + 1
vResolutionNumber = vRecordSet("resolutionNumber")
vTopic = vRecordSet("topic")
vDepartment = vRecordSet("department")
objTable.Cell(rowcount, 1).Range.Text =
vResolutionNumber
objTable.Cell(rowcount, 2).Range.Text = vTopic
objTable.Cell(rowcount, 3).Range.Text = vDepartment
'Go to next record, exit after last
vRecordSet.MoveNext
Loop
Set objTable = Nothing
Else
'if you ARE *else* (are .EOF), that means no record was
matched, tell the user
MsgBox "No possible match was found."
End If
End With
********************************************************
I have tried a number of ways to insert rows but the following code
which seems like it should work, claims that part or all of the 2nd
line is not in reference to a table.
objTable.Rows(rowcount).Select
Selection.InsertRowsBelow