J
jacobusroos via AccessMonster.com
I have 2 tables, the one is the Parent table which holds a column
TotalImprovedSQM this column is calculated by using the child table column
sum(improved) the criteria by which this happens is three column values in
both tables ERFNO PORTIONNO TOWNSHIP.
"Update MainTable set ImprovedSQMTotal = (SELECT Sum(structures.Improved) AS
ImprovementsSQMTotal FROM MainTable, structures where (MainTable.
BulkData1_ERFNO = structures.ERFNO) AND (MainTable.BulkData1_TOWNSHIPNAME =
structures.Township) AND (MainTable.BulkData1_PORTIONNO = structures.[Portion
No])) "
The above query in Access keeps givin me 3073 error and Both column do have
primary keys and IDs
Thus I wrote : Update Maintable
set ImprovedSQMTotal = DLookUp("sum(nz(Improved,0))","structures","(" &
MainTable.BulkData1_PORTIONNO & " = structures.[Portion No]) AND ('" &
MainTable.BulkData1_TOWNSHIPNAME & "' = structures.Township) AND (" &
MainTable.BulkData1_ERFNO & " = structures.ERFNO)")
This works but the problem is it takes exceptional long to do on 37000+
records
Is there a beter way, am I missing small details in my first attempt (the
first SQL statement) or is the second sql statement the only way ?
TotalImprovedSQM this column is calculated by using the child table column
sum(improved) the criteria by which this happens is three column values in
both tables ERFNO PORTIONNO TOWNSHIP.
"Update MainTable set ImprovedSQMTotal = (SELECT Sum(structures.Improved) AS
ImprovementsSQMTotal FROM MainTable, structures where (MainTable.
BulkData1_ERFNO = structures.ERFNO) AND (MainTable.BulkData1_TOWNSHIPNAME =
structures.Township) AND (MainTable.BulkData1_PORTIONNO = structures.[Portion
No])) "
The above query in Access keeps givin me 3073 error and Both column do have
primary keys and IDs
Thus I wrote : Update Maintable
set ImprovedSQMTotal = DLookUp("sum(nz(Improved,0))","structures","(" &
MainTable.BulkData1_PORTIONNO & " = structures.[Portion No]) AND ('" &
MainTable.BulkData1_TOWNSHIPNAME & "' = structures.Township) AND (" &
MainTable.BulkData1_ERFNO & " = structures.ERFNO)")
This works but the problem is it takes exceptional long to do on 37000+
records
Is there a beter way, am I missing small details in my first attempt (the
first SQL statement) or is the second sql statement the only way ?