小弟弄好了这个程序,却出错一大堆功能不能完全实现,不知道怎么办了,头都大了,各位大侠救命啊!
谢谢大家了!
[此贴子已经被作者于2007-10-22 20:04:25编辑过]
请问这段代码哪里有错呢?
Private Sub Command1_Click()
Dim rs_user As New ADODB.Recordset
If Trim(Text1.Text) = "" Then
MsgBox "客户级别不能为空,请输入!", vbOKOnly + vbExclamation, ""
Text1.SetFocus
ElseIf Trim(Text2.Text) = "" Then
MsgBox "客户号不能为空,请输入!", vbOKOnly + vbExclamation, ""
Text2.SetFocus
ElseIf Trim(Text3.Text) = "" Then
MsgBox "姓名不能为空,请输入!", vbOKOnly + vbExclamation, ""
Text3.SetFocus
ElseIf Trim(Text4.Text) = "" Then
MsgBox "性别不能为空,请输入!", vbOKOnly + vbExclamation, ""
Text4.SetFocus
ElseIf Trim(Text5.Text) = "" Then
MsgBox "出生年月不能为空,请输入!", vbOKOnly + vbExclamation, ""
Text5.SetFocus
ElseIf Trim(Text6.Text) = "" Then
MsgBox "职位不能为空,请输入!", vbOKOnly + vbExclamation, ""
Text6.SetFocus
ElseIf Trim(Text7.Text) = "" Then
MsgBox "地址不能为空,请输入!", vbOKOnly + vbExclamation, ""
Text7.SetFocus
ElseIf Trim(Text8.Text) = "" Then
MsgBox "联系方式不能为空,请输入!", vbOKOnly + vbExclamation, ""
Text8.SetFocus
Else
Dim connectionstring As String
connectionstring = "provider=Microsoft.Jet.OLEDB.4.0;data source=" & App.Path & "\base.mdb"
conn.Open connectionstring
sql = "select * from 客户信息 where 客户号='" & Text2.Text & "'"
rs_user.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_user.EOF Then
rs_user.AddNew
rs_user.Fields(0) = Text1.Text
rs_user.Fields(1) = Text2.Text
rs_user.Fields(2) = Text3.Text
rs_user.Fields(3) = Text4.Text
rs_user.Fields(4) = Text5.Text
rs_user.Fields(5) = Text6.Text
rs_user.Fields(6) = Text7.Text
rs_user.Fields(7) = Text8.Text
rs_user.Update
MsgBox "客户信息增加成功!", vbOKOnly + vbExclamation, ""
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text1.SetFocus
conn.Close
Else
MsgBox "该客户号已存在,请重新输入!", vbOKOnly + vbExclamation, ""
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text1.SetFocus
conn.Close
End If
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub