G
Guest
I have a loop that ends when one of the child recordsets doesn't have a value
that matches the parent. I'm stuck. Here's what I have:
Set db = CurrentDb
Set rsTM = db.OpenRecordset("SELECT * FROM Territory")
If Not rsTM.EOF Then
Do While Not rsTM.EOF
Set rsStrategicLBD = db.OpenRecordset("SELECT * " & _
"FROM [ShipmentsTerritoryLBD] " & _
"WHERE ProductC1ID = 2 AND [TERID] = " &
rsTM![TerritoryID])
StrategicLBDValue = Nz(rsStrategicLBD![SHIPDOLRS], 0)
When rsTM.TerritoryID does not have a matching value in rsStrategicLBD, the
code terminates. I was hoping that StrategicLBDValue would just set itself to
0 when that happens, hence StrategicLBDValue = Nz(rsStrategicLBD![SHIPDOLRS],
0)
but apparently I need more code.
Any suggestions would be a big help. Thanks!
that matches the parent. I'm stuck. Here's what I have:
Set db = CurrentDb
Set rsTM = db.OpenRecordset("SELECT * FROM Territory")
If Not rsTM.EOF Then
Do While Not rsTM.EOF
Set rsStrategicLBD = db.OpenRecordset("SELECT * " & _
"FROM [ShipmentsTerritoryLBD] " & _
"WHERE ProductC1ID = 2 AND [TERID] = " &
rsTM![TerritoryID])
StrategicLBDValue = Nz(rsStrategicLBD![SHIPDOLRS], 0)
When rsTM.TerritoryID does not have a matching value in rsStrategicLBD, the
code terminates. I was hoping that StrategicLBDValue would just set itself to
0 when that happens, hence StrategicLBDValue = Nz(rsStrategicLBD![SHIPDOLRS],
0)
but apparently I need more code.
Any suggestions would be a big help. Thanks!