|
Private Sub CommandButton4_Click()
'On Error Resume Next
Dim cnn As New ADODB.Connection
Dim Rs As New Recordset
Dim SQL As String
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & ThisWorkbook.Path & "\数据库.mdb"
'-----修改库存期初----
If UserForm3.Caption = "库存期初设置" Then
SQL = "Select * from 库存期初 WHERE 品名='" & TextBox2.Value & "' and 规格型号= '" & TextBox3.Value & "'"
Rs.Open SQL, cnn, 1, 3
If Rs.RecordCount > 0 Then
If MsgBox("已有商品【" & TextBox2.Value & "" & TextBox3.Value & "】的库存期初信息!是否修改?", vbYesNo, "开票系统") = vbNo Then
Exit Sub
Else
'-----更新库存期初----
SQL = "update 库存期初 set 件=" & TextBox4.Value & ",瓶=" & TextBox5.Value & " where 品名='" & TextBox2.Value & "' and 规格型号= '" & TextBox3.Value & "'"
cnn.Execute (SQL)
cnn.Close
Set cnn = Nothing
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
CommandButton3.Enabled = True
CommandButton4.Enabled = False
MsgBox ("已成功修改商品【" & TextBox2.Value & "" & TextBox3.Value & "】的库存期初信息!")
End If
End If
End If
Unload Me
Call 调用基础设置
End Sub |
|