I am trying to export text to a 2010 word document from an access 2010 database with DAO. I have successfully been able to export text from the main table tblLandSales via variables (below) and then subsequently a document. I used the following code:
Dim objWord As Word.Application
Dim docm As Word.Document
Dim rst As New ADODB.Recordset
Dim strSQL As String
Dim strLandSalesID As String
Dim strPropertyName As String
Dim strClass As String
strSQL = "SELECT * FROM qryLandSales " _
& "WHERE [LandSalesID]=" & [Me!LandSalesID]
rst.Open strSQL, CurrentProject.Connection, _
adOpenStatic, adLockReadOnly
With rst
strLandSalesID = Nz(.Fields("[LandSalesID]"))
strPropertyName = Nz(.Fields("[PropertyName]"))
strClass = Nz(.Fields("[Class]"))
Now I want to export other data from a one to many related table where [fk_tblLandSalesID] is the foreign key in the related table and tblLandSalesID is the primary key in the main table.
Any suggestions and thanks in advance.
Dim objWord As Word.Application
Dim docm As Word.Document
Dim rst As New ADODB.Recordset
Dim strSQL As String
Dim strLandSalesID As String
Dim strPropertyName As String
Dim strClass As String
strSQL = "SELECT * FROM qryLandSales " _
& "WHERE [LandSalesID]=" & [Me!LandSalesID]
rst.Open strSQL, CurrentProject.Connection, _
adOpenStatic, adLockReadOnly
With rst
strLandSalesID = Nz(.Fields("[LandSalesID]"))
strPropertyName = Nz(.Fields("[PropertyName]"))
strClass = Nz(.Fields("[Class]"))
Now I want to export other data from a one to many related table where [fk_tblLandSalesID] is the foreign key in the related table and tblLandSalesID is the primary key in the main table.
Any suggestions and thanks in advance.