esteiner
Programmer
- Oct 31, 2003
- 24
This is a follow up to thread
I was able to receive some great help for my initial problem, but have hit a snag when trying to apply this new method to a similar subprocedure.
I have a second scrubbing procedure that I run. The routine searches for the first numeric character in Field A and updates Field B with the remaining characters. This routine runs in about 3 minutes for 200,000 records. The file takes about 80 minutes to defragment. The number of records will soon increase to over 1 million.
Is there a more efficent method of updating the recordset without the fragmentation? Any help would be greatly appreciated. Below is the code for this second routine.
Private Sub cmdSplitMPN_Click()
On Error GoTo E_Handle
Dim rs As Recordset ' Recordset object
Dim strTableName As String ' Name of table where export records originate
Dim strSQL As String ' SQL String
Dim intRecordNum As Long ' Record Number being dealt with
Dim strMPN As String
Dim I As Integer
Dim strPrefix As String
Dim strBasenum As String
Dim blHasNum As Boolean
Set db = DBEngine(0)(0)
' Create the table name from where the export records will orginate
strTableName = "pull_inv_BRE"
strQuote = Chr$(34)
strSQL = "SELECT ManfPartNum, CorePartNum FROM " & strTableName & ""
Set rs = db.OpenRecordset(strSQL)
With rs
While Not (.BOF Or .EOF)
strMPN = !ManfPartNum
For I = 1 To Len(strMPN)
blHasNum = False
If IsNumeric(Mid(strMPN, I, 1)) Then
'number found, exit
blHasNum = True
Exit For
End If
Next I
If (blHasNum = True) Then
strBasenum = Right(strMPN, Len(strMPN) - I + 1)
.Edit
!CorePartNum = strBasenum
.Update
End If
.MoveNext
Wend
.Close
End With
sExit:
On Error Resume Next
rs.Close
Set rs = Nothing
Set db = Nothing
Reset
Exit Sub
E_Handle:
MsgBox Err.Description, vbOKOnly + vbCritical, "Error: " & Err.Number
Resume sExit
End Sub
Any help would again be appreciated. I am really stuck in the mud here.
Thank you
-Charlie
I was able to receive some great help for my initial problem, but have hit a snag when trying to apply this new method to a similar subprocedure.
I have a second scrubbing procedure that I run. The routine searches for the first numeric character in Field A and updates Field B with the remaining characters. This routine runs in about 3 minutes for 200,000 records. The file takes about 80 minutes to defragment. The number of records will soon increase to over 1 million.
Is there a more efficent method of updating the recordset without the fragmentation? Any help would be greatly appreciated. Below is the code for this second routine.
Private Sub cmdSplitMPN_Click()
On Error GoTo E_Handle
Dim rs As Recordset ' Recordset object
Dim strTableName As String ' Name of table where export records originate
Dim strSQL As String ' SQL String
Dim intRecordNum As Long ' Record Number being dealt with
Dim strMPN As String
Dim I As Integer
Dim strPrefix As String
Dim strBasenum As String
Dim blHasNum As Boolean
Set db = DBEngine(0)(0)
' Create the table name from where the export records will orginate
strTableName = "pull_inv_BRE"
strQuote = Chr$(34)
strSQL = "SELECT ManfPartNum, CorePartNum FROM " & strTableName & ""
Set rs = db.OpenRecordset(strSQL)
With rs
While Not (.BOF Or .EOF)
strMPN = !ManfPartNum
For I = 1 To Len(strMPN)
blHasNum = False
If IsNumeric(Mid(strMPN, I, 1)) Then
'number found, exit
blHasNum = True
Exit For
End If
Next I
If (blHasNum = True) Then
strBasenum = Right(strMPN, Len(strMPN) - I + 1)
.Edit
!CorePartNum = strBasenum
.Update
End If
.MoveNext
Wend
.Close
End With
sExit:
On Error Resume Next
rs.Close
Set rs = Nothing
Set db = Nothing
Reset
Exit Sub
E_Handle:
MsgBox Err.Description, vbOKOnly + vbCritical, "Error: " & Err.Number
Resume sExit
End Sub
Any help would again be appreciated. I am really stuck in the mud here.
Thank you
-Charlie