|
- Private Sub Command2_Click()
- Dim rs As New ADODB.Recordset
- Dim cnn As New ADODB.Connection
- Dim strWhar As String
- Dim sSQL As String
- Dim rsBom As String
- Set cnn = CurrentProject.Connection
- If IsNull(Me.BOM) Then
- MsgBox "请输入BOM"
- Exit Sub
- ElseIf Len(Me.BOM) < 4 Then
- MsgBox "请输入4位以上的BOM"
- Exit Sub
- End If
- strwhat = Left(Me.BOM, 4)
- sSQL = "select bom from 表1 where left(bom,4)='" & strwhat & "' order by id desc"
- rs.Open sSQL, cnn, adOpenKeyset, adLockReadOnly
- If rs.RecordCount <= 0 Then
- Me.NewBOM = Me.BOM
- Else
- rsBom = rs.Fields(0)
- Select Case Len(rsBom)
- Case 4
- Me.NewBOM = rsBom & "-1"
- Case Is > 4
- Me.NewBOM = Split(rsBom, "-")(0) & "-" & Val(Split(rsBom, "-")(1)) + 1
- End Select
- End If
- rs.Close
- Set rs = Nothing
- Set cnn = Nothing
- End Sub
复制代码 |
|