I have succeeded with retrieving subTable data from a One to many relationship, however, I'm stuck in an infinite loop processing the first record of the subtable and not moving to the next one. Any Help, Thanks in advance.
Dim db As DAO.Database
Dim rstLandData As DAO.Recordset
Set db = CurrentDb
Set rstLandData = db.OpenRecordset("qryLandData", dbOpenDynaset)
Dim strLandType As String
Dim strAcreage As String
Dim strFrontage As String
Dim strZoning As String
Dim strUtilities As String
Dim strTopography As String
Dim strAccess As String
Dim strShape As String
Dim strLandScaping As String
Dim strFloodData As String
strSQL = "SELECT tblLandData.LandDataID,tblLandData.fk_LandSaleID " _
& ",tblLandData.Acreage,tblLandData.Frontage,tblLandData.Zoning " _
& ", tblLandData.Utilities,tblLandData.Topography, tblLandData.Access " _
& ", tblLandData.Shape, tblLandData.Landscaping,tblLandData.FloodData " _
& "FROM tblLandSales INNER JOIN tblLandData ON tblLandSales.LandSalesID = tblLandData.fk_LandSaleID;"
rst.Open strSQL, CurrentProject.Connection, _
adOpenStatic, adLockReadOnly
Do While Not rstLandData.EOF
With rstLandData
strLandType = Nz(.Fields("LandType"))
strAcreage = Nz(.Fields("Acreage"))
strFrontage = Nz(.Fields("Frontage"))
strZoning = Nz(.Fields("Zoning"))
strUtilities = Nz(.Fields("Utilities"))
strTopography = Nz(.Fields("Topography"))
strAccess = Nz(.Fields("Access"))
strShape = Nz(.Fields("Shape"))
strLandScaping = Nz(.Fields("LandScaping"))
strFloodData = Nz(.Fields("FloodData"))
.Close
End With
objWord.Run "GHLandCompTable3"
With objWord.Selection
' .MoveRight Unit:=wdCell, Count:=2
.TypeText strLandType
.MoveRight Unit:=wdCell, Count:=2
.TypeText strAcreage
.MoveRight Unit:=wdCell, Count:=2
.TypeText strFrontage
.MoveRight Unit:=wdCell, Count:=2
.TypeText strZoning
.MoveRight Unit:=wdCell, Count:=2
.TypeText strUtilities
.MoveRight Unit:=wdCell, Count:=2
.TypeText strTopography
.MoveRight Unit:=wdCell, Count:=2
.TypeText strAccess
.MoveRight Unit:=wdCell, Count:=2
.TypeText strShape
.MoveRight Unit:=wdCell, Count:=2
.TypeText strLandScaping
.MoveRight Unit:=wdCell, Count:=2
.TypeText strFloodData
.MoveUp Unit:=wdLine, Count:=2
End With
rstLandData.MoveNext
Loop
End Sub
Dim db As DAO.Database
Dim rstLandData As DAO.Recordset
Set db = CurrentDb
Set rstLandData = db.OpenRecordset("qryLandData", dbOpenDynaset)
Dim strLandType As String
Dim strAcreage As String
Dim strFrontage As String
Dim strZoning As String
Dim strUtilities As String
Dim strTopography As String
Dim strAccess As String
Dim strShape As String
Dim strLandScaping As String
Dim strFloodData As String
strSQL = "SELECT tblLandData.LandDataID,tblLandData.fk_LandSaleID " _
& ",tblLandData.Acreage,tblLandData.Frontage,tblLandData.Zoning " _
& ", tblLandData.Utilities,tblLandData.Topography, tblLandData.Access " _
& ", tblLandData.Shape, tblLandData.Landscaping,tblLandData.FloodData " _
& "FROM tblLandSales INNER JOIN tblLandData ON tblLandSales.LandSalesID = tblLandData.fk_LandSaleID;"
rst.Open strSQL, CurrentProject.Connection, _
adOpenStatic, adLockReadOnly
Do While Not rstLandData.EOF
With rstLandData
strLandType = Nz(.Fields("LandType"))
strAcreage = Nz(.Fields("Acreage"))
strFrontage = Nz(.Fields("Frontage"))
strZoning = Nz(.Fields("Zoning"))
strUtilities = Nz(.Fields("Utilities"))
strTopography = Nz(.Fields("Topography"))
strAccess = Nz(.Fields("Access"))
strShape = Nz(.Fields("Shape"))
strLandScaping = Nz(.Fields("LandScaping"))
strFloodData = Nz(.Fields("FloodData"))
.Close
End With
objWord.Run "GHLandCompTable3"
With objWord.Selection
' .MoveRight Unit:=wdCell, Count:=2
.TypeText strLandType
.MoveRight Unit:=wdCell, Count:=2
.TypeText strAcreage
.MoveRight Unit:=wdCell, Count:=2
.TypeText strFrontage
.MoveRight Unit:=wdCell, Count:=2
.TypeText strZoning
.MoveRight Unit:=wdCell, Count:=2
.TypeText strUtilities
.MoveRight Unit:=wdCell, Count:=2
.TypeText strTopography
.MoveRight Unit:=wdCell, Count:=2
.TypeText strAccess
.MoveRight Unit:=wdCell, Count:=2
.TypeText strShape
.MoveRight Unit:=wdCell, Count:=2
.TypeText strLandScaping
.MoveRight Unit:=wdCell, Count:=2
.TypeText strFloodData
.MoveUp Unit:=wdLine, Count:=2
End With
rstLandData.MoveNext
Loop
End Sub