|
Private Sub cmdadd2_Click()
Dim a As String
Dim b As String
Dim db As Database
Dim rs As DAO.Recordset
Dim str As String
a = Nz(DLookup("材料名称", "材料价格表", "材料名称='" & Nz(Me.材料名称, "") & "'"), "")
If a = "" Then
a = Nz(Me.材料名称, "")
b = Nz(Me.材料价格, 0)
Set db = CurrentDb
'Set rs = db.OpenRecordset
str = "insert into 材料价格表(材料名称,价格) values('" & a & "'," & b & ")"
db.Execute (str)
MsgBox "新材料添加成功"
Me.材料名称 = Null
Me.材料价格 = Null
Else
MsgBox "该材料已存在,请重新输入!"
Me.材料名称 = Null
Me.材料价格 = Null
End If
End Sub |
|