如题:代码如下:
Private Sub Command1_Click()
If Text1 = "" Or Text2 = "" Or Text3 = "" Or Text4 = "" Or Text5 = "" Then
MsgBox "用户信息不能为空",vbInformation + vbOKOnly, "提示"
Else
If Text2 <> Text3 Then
MsgBox "密码不一致", vbInformation + vbOKOnly, "提示"
Text2.SetFocus
Text2 = ""
Text3 = ""
Else
Adodc1.Refresh
Adodc1.Recordset.Fields![用户].Value = Text1.Text
If Adodc1.Recordset.RecordCount > 0 Then
MsgBox "用户已存在", vbInformation + vbOKOnly, "提示"
Text1.SetFocus
Text1 = ""
Text2 = ""
Text3 = ""
Else
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields![用户] = Text1.Text
Adodc1.Recordset.Fields![密码] = Text2.Text
Adodc1.Recordset.Fields![Email] = Text4.Text
Adodc1.Recordset.Fields![分机] = Text5.Text
Adodc1.Recordset.Update
MsgBox "用户添加成功¦", vbInformation + vbOKOnly, "提示"
Text1.SetFocus
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
End If
End If
End If
End Sub
另:再请教一下如果要检查Email格式是否正确应该怎样写!
Private Sub Command1_Click()
If Text1 = "" Or Text2 = "" Or Text3 = "" Or Text4 = "" Or Text5 = "" Then
MsgBox "用户信息不能为空",vbInformation + vbOKOnly, "提示"
Else
If Text2 <> Text3 Then
MsgBox "密码不一致", vbInformation + vbOKOnly, "提示"
Text2.SetFocus
Text2 = ""
Text3 = ""
Else
Adodc1.Refresh
Adodc1.Recordset.Fields![用户].Value = Text1.Text
If Adodc1.Recordset.RecordCount > 0 Then
MsgBox "用户已存在", vbInformation + vbOKOnly, "提示"
Text1.SetFocus
Text1 = ""
Text2 = ""
Text3 = ""
Else
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields![用户] = Text1.Text
Adodc1.Recordset.Fields![密码] = Text2.Text
Adodc1.Recordset.Fields![Email] = Text4.Text
Adodc1.Recordset.Fields![分机] = Text5.Text
Adodc1.Recordset.Update
MsgBox "用户添加成功¦", vbInformation + vbOKOnly, "提示"
Text1.SetFocus
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
End If
End If
End If
End Sub
另:再请教一下如果要检查Email格式是否正确应该怎样写!
Adodc1.Refresh
Adodc1.Recordset.Find "[用户名]= '" & Text1 & "'"
If Adodc1.Recordset.EOF = False Then
MsgBox "用户已存在", vbInformation + vbOKOnly, "提示"
Text1.SetFocus
Text1 = ""
Text2 = ""
Text3 = ""
好像是可以了,谢谢两位的热心帮助!谢谢!!
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from yourTable where 用户=" & Text1.Text
Adodc1.Refresh If Adodc1.Recordset.RecordCount > 0 Then
MsgBox "用户已存在", vbInformation + vbOKOnly, "提示"
Text1.SetFocus
Text1 = ""
Text2 = ""
Text3 = ""
Else
这句话不会起到筛选作用
后面的方法用find是对的。