小弟初学 ,求大神指点一二,求增加一条新记录的代码
Private Sub Command1_Click()If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text5.Text Or Text6.Text Then
MsgBox "请将数据填写完整!", 64, "提示"
Exit Sub
End If
Call (conn)
Dim A As String
Dim b As New ADODB.Recordset
A = "select * from试剂库 where 试剂名称='" & Text1.Text & "'"
b.Open A, conn, adOpenKeyset, adLockPessimistic
If b.EOF = False Then
MsgBox "材料名称已存在,请重新输入", 48, "提示"
conn.Close
Set conn = Nothing
Exit Sub
End If
If b.EOF = True Then
With b
.AddNew
.Fields("试剂名称") = Text1.Text
.Fields("规格") = Text2.Text
.Fields("采购人") = Text3.Text
.Fields("生产日期") = Text4.Text
Fields("有效日期") = Text5.Text
Fields("数量") = Text6.Text
.Update
End With
End If
MsgBox "添加成功!", 64, "提示"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Adodc1.Refresh
试剂库.Refresh
DataGrid1.Refresh
conn.Close
Set conn = Nothing