Good afternoon.
I have a table that is generated from a MTQ (Mate Table Query). The table that is generated has 7 columns and around 650,000 records and growing each day.
Due to the reporting nature I have the need to add sequence #'s and record counts to the table. I am doing this via 2 modules. The first creates 3 additional fields and appends them to the table. The second module loops thru the recordset until the record count reaches the last record (.movelast).
Anyhow what happens is the code runs fine until it thows the runtime error of 3049. As far as I can tell what is happening is the database size is exploding in size until it reaches the 2GB threshold then just quits on me.
So my question to all of you pros out there is how do I get around this problem and still get my table populated via my code. Any suggestions and or recommendations are welcome and appricated
Here is the code for the 2 modules:
======================================
Option Compare Database
------------------------------------------------
Sub AddColumnsToTempWFTbl()
'Adds 3 columns to the tempTbl
' 1. [Record #] -- Record Counter
' 2. [RT Seq]Rev --Trac Overall Seq Counter
' 3. [Ver_Seq]-- Rev-Trac / Seq Counter
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
'Initialize
Set db = CurrentDb()
Set tdf = db.TableDefs("TmpTbl /RSC/T_RM_3D - Workflow - Ordered List") ' table already exist
'Add a field to the table.
tdf.Fields.Append tdf.CreateField("Record", dbLong)
tdf.Fields.Append tdf.CreateField("RT_Seq", dbInteger)
tdf.Fields.Append tdf.CreateField("Ver_Seq", dbInteger)
'Destroy object variables
Set fld = Nothing
Set tdf = Nothing
Set db = Nothing
End Sub
------------------------------------------------
Sub populateWFSeqValues()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim lRecordsInTbl As Long
Dim lCurrentRec As Long
Dim lRTNumCurrentRecord As Long 'Rev-Trac # of Current Record
Dim lRTNumPrevRecord As Long 'Rev-Trac # of Previous Record
Dim iVerNumCurrentRecord As Integer 'Version # of Current Record
Dim iVerNumPrevRecord As Integer 'Version # of Previous Record
Dim iseqRT As Integer 'Rev-Trac WF Sequence Counter (All steps)
Dim iseqVer As Integer 'Rev-Trac WF Sequence Counter by Version #
'*** Initialize Variables
Set db = CurrentDb()
Set rs = db.OpenRecordset("TmpTbl /RSC/T_RM_3D - Workflow - Ordered List")
lCurrentRec = 1
iseqRT = 1
iseqVer = 1
With rs
.MoveFirst
.MoveLast
lRecordsInTbl = .RecordCount 'Record Count
.MoveFirst
lRTNumCurrentRecord = rs.Fields("Rev-Trac #") 'RevTrac # of 1st Record
iVerNumCurrentRecord = rs.Fields("WF_Version") 'WF Version # of 1st Record
End With
'*** Create Values for 1st Record in table.
With rs
.MoveFirst
.Edit
![Record] = 1
![RT_Seq] = 1
![Ver_Seq] = 1
.Update
Do While lCurrentRec <= lRecordsInTbl
lRTNumPrevRecord = lRTNumCurrentRecord 'Get values for Prev RT # record (Current to Prev variable)
iVerNumPrevRecord = iVerNumCurrentRecord 'Get values for Prev Ver # record (Current to Prev variable)
lCurrentRec = lCurrentRec + 1 'Increment Current Record + 1 for each else statement executed in loop
.MoveNext 'Move to next record and update current record variables
lRTNumCurrentRecord = rs.Fields("Rev-Trac #") 'Get Current records Rev-Trac #
iVerNumCurrentRecord = rs.Fields("WF_Version") 'Get Current records Version #
.Edit
![Record] = lCurrentRec 'input incremented record # in to record set
.Update
If lRTNumCurrentRecord = lRTNumPrevRecord Then 'Test if RT# from Prev matches Current records' RT#
iseqRT = iseqRT + 1 'If Prev & Curret RT # field same then increment by +1
If iVerNumCurrentRecord = iVerNumPrevRecord Then 'Test if Ver# from Prev matches Current records' Ver#
iseqVer = iseqVer + 1 'If Prev & Curret Ver # field same then increment by +1
Else
iseqVer = 1 'Current Ver # <> Prev Ver # reset iseqVer to 1
End If
Else
iseqRT = 1 'Current RT # <> Prev RT # reset iseqRT to 1
End If
'*** Populate RT_Seq # and Ver_Seq fields with values from above IF statement
.Edit
![RT_Seq] = iseqRT
![Ver_Seq] = iseqVer
.Update
Loop
End With
MsgBox lRecordsInTbl
'Clear DB and RS values from memory
Set db = Nothing
Set rs = Nothing
Set tblDef = Nothing
End Sub
======================================
Thanks in advance
I have a table that is generated from a MTQ (Mate Table Query). The table that is generated has 7 columns and around 650,000 records and growing each day.
Due to the reporting nature I have the need to add sequence #'s and record counts to the table. I am doing this via 2 modules. The first creates 3 additional fields and appends them to the table. The second module loops thru the recordset until the record count reaches the last record (.movelast).
Anyhow what happens is the code runs fine until it thows the runtime error of 3049. As far as I can tell what is happening is the database size is exploding in size until it reaches the 2GB threshold then just quits on me.
So my question to all of you pros out there is how do I get around this problem and still get my table populated via my code. Any suggestions and or recommendations are welcome and appricated
Here is the code for the 2 modules:
======================================
Option Compare Database
------------------------------------------------
Sub AddColumnsToTempWFTbl()
'Adds 3 columns to the tempTbl
' 1. [Record #] -- Record Counter
' 2. [RT Seq]Rev --Trac Overall Seq Counter
' 3. [Ver_Seq]-- Rev-Trac / Seq Counter
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
'Initialize
Set db = CurrentDb()
Set tdf = db.TableDefs("TmpTbl /RSC/T_RM_3D - Workflow - Ordered List") ' table already exist
'Add a field to the table.
tdf.Fields.Append tdf.CreateField("Record", dbLong)
tdf.Fields.Append tdf.CreateField("RT_Seq", dbInteger)
tdf.Fields.Append tdf.CreateField("Ver_Seq", dbInteger)
'Destroy object variables
Set fld = Nothing
Set tdf = Nothing
Set db = Nothing
End Sub
------------------------------------------------
Sub populateWFSeqValues()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim lRecordsInTbl As Long
Dim lCurrentRec As Long
Dim lRTNumCurrentRecord As Long 'Rev-Trac # of Current Record
Dim lRTNumPrevRecord As Long 'Rev-Trac # of Previous Record
Dim iVerNumCurrentRecord As Integer 'Version # of Current Record
Dim iVerNumPrevRecord As Integer 'Version # of Previous Record
Dim iseqRT As Integer 'Rev-Trac WF Sequence Counter (All steps)
Dim iseqVer As Integer 'Rev-Trac WF Sequence Counter by Version #
'*** Initialize Variables
Set db = CurrentDb()
Set rs = db.OpenRecordset("TmpTbl /RSC/T_RM_3D - Workflow - Ordered List")
lCurrentRec = 1
iseqRT = 1
iseqVer = 1
With rs
.MoveFirst
.MoveLast
lRecordsInTbl = .RecordCount 'Record Count
.MoveFirst
lRTNumCurrentRecord = rs.Fields("Rev-Trac #") 'RevTrac # of 1st Record
iVerNumCurrentRecord = rs.Fields("WF_Version") 'WF Version # of 1st Record
End With
'*** Create Values for 1st Record in table.
With rs
.MoveFirst
.Edit
![Record] = 1
![RT_Seq] = 1
![Ver_Seq] = 1
.Update
Do While lCurrentRec <= lRecordsInTbl
lRTNumPrevRecord = lRTNumCurrentRecord 'Get values for Prev RT # record (Current to Prev variable)
iVerNumPrevRecord = iVerNumCurrentRecord 'Get values for Prev Ver # record (Current to Prev variable)
lCurrentRec = lCurrentRec + 1 'Increment Current Record + 1 for each else statement executed in loop
.MoveNext 'Move to next record and update current record variables
lRTNumCurrentRecord = rs.Fields("Rev-Trac #") 'Get Current records Rev-Trac #
iVerNumCurrentRecord = rs.Fields("WF_Version") 'Get Current records Version #
.Edit
![Record] = lCurrentRec 'input incremented record # in to record set
.Update
If lRTNumCurrentRecord = lRTNumPrevRecord Then 'Test if RT# from Prev matches Current records' RT#
iseqRT = iseqRT + 1 'If Prev & Curret RT # field same then increment by +1
If iVerNumCurrentRecord = iVerNumPrevRecord Then 'Test if Ver# from Prev matches Current records' Ver#
iseqVer = iseqVer + 1 'If Prev & Curret Ver # field same then increment by +1
Else
iseqVer = 1 'Current Ver # <> Prev Ver # reset iseqVer to 1
End If
Else
iseqRT = 1 'Current RT # <> Prev RT # reset iseqRT to 1
End If
'*** Populate RT_Seq # and Ver_Seq fields with values from above IF statement
.Edit
![RT_Seq] = iseqRT
![Ver_Seq] = iseqVer
.Update
Loop
End With
MsgBox lRecordsInTbl
'Clear DB and RS values from memory
Set db = Nothing
Set rs = Nothing
Set tblDef = Nothing
End Sub
======================================
Thanks in advance