以下是引用keanu在2005-1-11 8:26:31的发言:
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 = Me.材料名称
b = Me.材料名称
If IsNull(Me.材料名称) Or Trim(Me.材料名称) = "" Then
MsgBox "材料名称不能为空!"
Else
a = DLookup("材料名称", "材料价格表", "材料名称='" & Me.材料名称 & "'")←提示这里是黄色的,出错
If IsNull(a) = False Then
Set db = CurrentDb
'Set rs = db.OpenRecordset
str = "insert into 材料价格表(材料名称,价格) values('" & b & "','" & Me.材料价格 & "')"
db.Execute (str)
MsgBox "新材料添加成功"
Me.材料名称 = Null
Me.材料价格 = Null
Else
MsgBox "该材料已存在,请重新输入!"
Me.材料名称 = Null
Me.材料价格 = Null
End If
End If
End Sub
谁帮我分析一下。
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) | Powered by Discuz! X3.3 |