VB用户密码登陆代码问题

来源:百度知道 编辑:UC知道 时间:2024/06/07 20:43:46
我的代码

Private Sub cmdOK_Click()
Dim str As String
str1 = textID.Text
Data1.Recordset.FindFirst "userID ='" & str1 & "'"
If Data1.Recordset.NoMatch Then
MsgBox "没有该用户!", vbCritical, "用户登陆验证"

Else
If Data1.Recordset.Fields("userpwd") = textpwd.Text Then
Add.Show
Unload Me
Else
MsgBox "密码不正确!", vbCritical, "用户登陆验证"
End If
End If
str1 = textID.Text
str2 = textpwd.Text

End Sub

Private Sub Command1_Click()

End Sub

Private Sub Form_Load()
Data1.DatabaseName = App.Path & "\数据库\哈尔滨旅游信息.mdb"
Data1.RecordSource = "密码"
End Sub

问题出在第四句Data1.Recordset.FindFirst "userID ='" & str1 & "'"
他说表达式中数据类型不匹配...这是为啥??

Data.Recordset.FindFirst
感觉Recordset不是Data的一个属性

或者("userID ='" & str1 & "'")
不是Data.Recordset.FindFirst 所需的数据类型

我晕....你看看你定义的变量名是什么,再看看你用的是不是那变量