|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
各位老师我依据下面的代码将数据进行拆分(将这个LEVE_ID_MAX值为15拆分),追加到tblTemp表中,但是出现一个问题所需要时间太长1个多小时,表"tblTemp追踪单整理"一共3000条数据,请问有没有其他VBA代码,来快速生成数据,节省时间,谢谢, 帮助修改一下附件,谢谢
Sub 拆分()
On Error Resume Next
Dim S As String
Dim rst1 As ADODB.Recordset
Dim str1 As String
Dim x As Integer
str1 = "SELECT * FROM tblTemp追踪单整理"
Set rst1 = New ADODB.Recordset
rst1.Open str1, CurrentProject.Connection, adOpenStatic, adLockReadOnly
If rst1.RecordCount > 0 Then
rst1.MoveFirst
x = 0
Set rst = CurrentDb.OpenRecordset("tblTemp", dbOpenDynaset)
For i = 1 To rst1.RecordCount
For ii = 1 To rst1.Fields("LEVE_ID_MAX")
S = ii
DoCmd.RunSQL "INSERT INTO tblTemp SELECT '" & S & "' AS LEVE_ID, '" & rst1.Fields("END_ITEM") & "' AS END_ITEM, '" & rst1.Fields("ITEM_DESC") & "' AS ITEM_DESC"
x = x + 1
Next
rst1.MoveNext
Next
End If
MsgBox "数据更新完毕,此次操作共新增:" & x & " 条记录!", vbInformation + vbOKOnly, "Level_ID数据更新"
End Sub
|
|
|