|
完善一下:- Private Sub Command5_Click()
- Dim intS As Integer
- Dim intE As Integer
- Dim i As Integer, p As Integer
- Dim bln As Boolean
- Dim strSQL As String
- If Not IsNull(Me.序列号) Then
- p = InStr(Me.序列号, "-")
- If p > 0 Then
- bln = True
- intS = Left(Me.序列号, p - 1)
- intE = Right(Me.序列号, Len(Me.序列号) - p)
- Else
- bln = False
- End If
- Else
- Exit Sub
- End If
- If bln Then
- For i = intS To intE
- strSQL = "INSERT INTO 总表2 (材料编号,材料名称,不良原因,处理方式,不良品数量,序列号 )values('" & _
- Me.材料编号 & "','" & Me.材料名称 & "','" & Me.不良原因 & "','" & Me.处理方式 & "'," & _
- Me.不良品数量 & "," & i & ")"
- CurrentDb.Execute strSQL
- Next
- Else
- strSQL = "INSERT INTO 总表2 (材料编号,材料名称,不良原因,处理方式,不良品数量,序列号 )values('" & _
- Me.材料编号 & "','" & Me.材料名称 & "','" & Me.不良原因 & "','" & Me.处理方式 & "'," & _
- Me.不良品数量 & "," & Me.序列号 & ")"
- CurrentDb.Execute strSQL
- End If
- End Sub
复制代码 |
|