J
jj
Hi NG
I have two tables with approximately T1 = 1.5 million and T2 = 75000
records. I need to opdate T1 with information from T2, but my problem is
that it takes op very much space - and I dont know why - when I compact and
repair the database then it is reduced again, but I cant do that
automatically when running the procedure. Can anyone see through my problem.
?
My code is below:
Sub update_Jobnr
Set db = CurrentDb
Set rstCom = db.OpenRecordset("select Com from T2 group by Com")
While Not rstCom .EOF
Set rst = db.OpenRecordset("Select * from T2 where Com = " &
rstCom.Fields("Com") & "")
Set rst1 = db.OpenRecordset("select * from T1 WHERE Com= " &
rst.Fields("Com") , dbOpenDynaset)
While Not rst.EOF
If Not IsNull(rst.Fields("kode")) Then
If rst.Fields("side").Value = "U" Then
rst1.Filter = "Com= " & rst.Fields("Com") & " and KODE = " &
rst.Fields("kode") & " and no >= " & rst.Fields("From") & " And no <= " &
rst.Fields("To") & " and (no mod 2 = 1)"
Set rst2 = rst1.OpenRecordset()
While Not rst2.EOF
With rst2
.Edit
![Jobnr] = rst.Fields("Job")
.Update
End With
rst2.MoveNext
Wend
rst2.Close
Else
'The same code just with (no mod 2 = 0)
end if
End If
rst.MoveNext
Wend
rst.Close
rstCom.MoveNext
Wend
rstCom.Close
end sub
TIA
JJ
I have two tables with approximately T1 = 1.5 million and T2 = 75000
records. I need to opdate T1 with information from T2, but my problem is
that it takes op very much space - and I dont know why - when I compact and
repair the database then it is reduced again, but I cant do that
automatically when running the procedure. Can anyone see through my problem.
?
My code is below:
Sub update_Jobnr
Set db = CurrentDb
Set rstCom = db.OpenRecordset("select Com from T2 group by Com")
While Not rstCom .EOF
Set rst = db.OpenRecordset("Select * from T2 where Com = " &
rstCom.Fields("Com") & "")
Set rst1 = db.OpenRecordset("select * from T1 WHERE Com= " &
rst.Fields("Com") , dbOpenDynaset)
While Not rst.EOF
If Not IsNull(rst.Fields("kode")) Then
If rst.Fields("side").Value = "U" Then
rst1.Filter = "Com= " & rst.Fields("Com") & " and KODE = " &
rst.Fields("kode") & " and no >= " & rst.Fields("From") & " And no <= " &
rst.Fields("To") & " and (no mod 2 = 1)"
Set rst2 = rst1.OpenRecordset()
While Not rst2.EOF
With rst2
.Edit
![Jobnr] = rst.Fields("Job")
.Update
End With
rst2.MoveNext
Wend
rst2.Close
Else
'The same code just with (no mod 2 = 0)
end if
End If
rst.MoveNext
Wend
rst.Close
rstCom.MoveNext
Wend
rstCom.Close
end sub
TIA
JJ