我只是想做个用户登录界面的代码,先做了一个函数的测试。结果发现了一个很莫名的问题。
不论我在文本框me.name做不做数据怎么全是反映msgbox "a"?
怎么这都可能出错呢?
Private Sub login_Click()
If Nz(Me.name) <> "" Then
MsgBox "a"
Else
MsgBox "请输入用户名!", vbQuestion
End If
End Sub
Private Sub login_Click()
Dim sql1 As String
If Nz(Me.namein) <> "" Then
If isnull(DLookup("姓名", "表2", "姓名='& me.namein.value &'")) Then
MsgBox "该用户名不存在,请重新输入"
Me.namein = ""
Exit Sub
Else
sql1 = "select [密码] from [表2] where [姓名]='& me.namein.value &'"
If sql1 = "& me.password.value &" Then
MsgBox "欢迎登陆"
Else
MsgBox "密码错误"
Me.password = ""
End If
End If
Else
MsgBox "请输入用户名!", vbQuestion
End If
End Sub