|
推荐
楼主 |
发表于 2021-5-15 17:37:21
|
只看该作者
tmtony老师不敢在各位老师们面前造次,下面是具体代码,见笑了
Option Compare Database
Private Sub Command0_Click()
Dim rs As ADODB.Recordset
Dim rs1 As ADODB.Recordset
Dim stemp As String
Dim stemp1 As String
Set rs = New ADODB.Recordset
Set rs1 = New ADODB.Recordset
strTemp = "Select sn From tbl序列数 group by sn"
rs.Open strTemp, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
CurrentDb.Execute "DELETE * FROM 表1" '提前到rs1打开之前对表进行情况
stemp1 = "select * from 表1"
rs1.Open stemp1, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
Dim intCount, intCount1 As Integer, intCount2 As Integer
Dim i As Integer
For i = 1 To rs.RecordCount
rs1.AddNew
rs1!sn = rs!sn
rs1.Update
rs.MoveNext 'rs才是要循环的记录集
Next
rs1.Close
Set rs1 = Nothing
intCount1 = DCount("SN", "表1")
MsgBox "已生成: " & Format(intCount1, "#,###") & " 条 新记录!请查看报表!", vbInformation, "生成序列数"
End Sub
|
|