Private Sub 运算_Click()
Dim sql As String
Dim i As Long
Dim x As String
DoCmd.SetWarnings no
sql = "DELETE * FROM 表2;"
DoCmd.RunSQL sql
Do While Not (IsNull(Me.ID1))
If Val(Me.ID1) - Val(Me.ID) > 1 Then
i = 0
Do While i < Val(Me.ID1) - Val(Me.ID) - 1
i = i + 1
x = Me.ID.Value + i
sql = "INSERT INTO 表2 ( ID ) SELECT " & x & " AS ID;"
DoCmd.RunSQL sql
Loop
End If
DoCmd.GoToRecord acForm, "窗体", acNext, 1
Loop
sql = "UPDATE 表2 SET 表2.ID = Format([ID],'0000');"
DoCmd.RunSQL sql
Me.Child5.Form.Requery
End Sub