gerard1979
MIS
I have to set up a wordDoc from Access 2000. I make a few recordset which handle this for me, but stuck on filling a table, I don't understand the neccesary syntaxis.
I set up the doc with bookmarks. I make the table in the doc. It's only one table. I set the values in the first row and need a nested loop of 2 recordsets to fill it. I have something like this but get strange errors.:
Dim mytable As Table
Dim cnn As ADODB.Connection
Dim rst, rstDetails As New ADODB.Recordset
Set cnn = New ADODB.Connection
Set cnn = CurrentProject.Connection
Set rst = New ADODB.Recordset
Set rstDetails = New ADODB.Recordset
'voer de query uit om de juiste regel te vinden in die betrekking heeft op de offerte
strSQL = "Select * From tblLocatie WHERE [loc_werkbonID] = " & TempWerkbonID
rst.Open strSQL, cnn, adOpenStatic, adLockReadOnly
rst.MoveLast
rst.MoveFirst
Dim rij As Integer
Dim TableStr As String
TableStr = ""
rij = 3
Set mytable = ActiveDocument.Tables(1)
With rst
mytable.Cell(rij, 1).Range.InsertAfter .Fields("loc_beschrijving"
rij = rij + 1
While Not .EOF
strSQL = "SELECT * FROM qryTestLocaties WHERE [locatie_ID] = " & .Fields("locatie_ID"
rstDetails.Open strSQL, cnn, adOpenStatic, adLockReadOnly
While Not rstDetails.EOF
TableStr = TableStr & rstDetails.Fields("sub_omschrijving"
& vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbCr
mytable.Cell(rij, 1).Range.InsertAfter TableStr
rij = rij + 1
.MoveNext
Wend
Wend
.Close
End With
can anybody tell me something about syntax or give good documents about it, or sample code?
Thnx in advance,
Gerard
I set up the doc with bookmarks. I make the table in the doc. It's only one table. I set the values in the first row and need a nested loop of 2 recordsets to fill it. I have something like this but get strange errors.:
Dim mytable As Table
Dim cnn As ADODB.Connection
Dim rst, rstDetails As New ADODB.Recordset
Set cnn = New ADODB.Connection
Set cnn = CurrentProject.Connection
Set rst = New ADODB.Recordset
Set rstDetails = New ADODB.Recordset
'voer de query uit om de juiste regel te vinden in die betrekking heeft op de offerte
strSQL = "Select * From tblLocatie WHERE [loc_werkbonID] = " & TempWerkbonID
rst.Open strSQL, cnn, adOpenStatic, adLockReadOnly
rst.MoveLast
rst.MoveFirst
Dim rij As Integer
Dim TableStr As String
TableStr = ""
rij = 3
Set mytable = ActiveDocument.Tables(1)
With rst
mytable.Cell(rij, 1).Range.InsertAfter .Fields("loc_beschrijving"
rij = rij + 1
While Not .EOF
strSQL = "SELECT * FROM qryTestLocaties WHERE [locatie_ID] = " & .Fields("locatie_ID"
rstDetails.Open strSQL, cnn, adOpenStatic, adLockReadOnly
While Not rstDetails.EOF
TableStr = TableStr & rstDetails.Fields("sub_omschrijving"
mytable.Cell(rij, 1).Range.InsertAfter TableStr
rij = rij + 1
.MoveNext
Wend
Wend
.Close
End With
can anybody tell me something about syntax or give good documents about it, or sample code?
Thnx in advance,
Gerard