|
各位老师我依据下面的代码将数据进行拆分(将这个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
Dim VarReturn As Variant
str1 = "SELECT * FROM tblTemp追踪单整理"
Set rst1 = New ADODB.Recordset
rst1.Open str1, CurrentProject.Connection, adOpenStatic, adLockReadOnly
VarReturn = SysCmd(acSysCmdSetStatus, " 数据正在生成中...稍后... ")
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
'ReturnValue = SysCmd(acSysCmdUpdateMeter, x)
VarReturn = SysCmd(acSysCmdSetStatus, "数据已完成! ")
MsgBox "数据更新完毕,此次操作共新增:" & x & " 条记录!", vbInformation + vbOKOnly, "Level_ID数据更新"
End Sub
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|