卡地亚手表兰州维修店:SQL语句出错了

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/29 14:53:02
这是在Access中的一段VBA写的代码:
Private Sub cmdyes_Click()
Dim temp As String
If IsNull(Me![user_name]) Or IsNull(Me![user_password]) Then
MsgBox "你输入的用户名和密码不能为空,请重新输入! ", vbOKOnly, "警告信息"
Else
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
temp = "Select * From user Where 注册名称 = " & "'" & Me![user_name] & "'" & " and 注册密码 = '& Me![user_password] &" '"
MsgBox temp, vbOKOnly, "警告信息"
rs.Open temp, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If rs.RecordCount > 0 Then
DoCmd.Close
DoCmd.OpenForm "切换面版", acNormal, "", "", acReadOnly, acWindowNormal
Else
MsgBox "你输入的用户名和密码有误,请重新输入!", vbOKOnly, "警告信息"
End If
rs.Close
Set rs = Nothing
End If

End Sub
运行后总是提示“FROM 子句语法错误”
怎么办呀?
temp = "Select * From user Where 注册名称 = '" & Me![user_name] & "'" & " and 注册密码 = '" & Me![user_password] & "'"

temp = "Select * From user Where 注册名称 = " & "'" & Me![user_name] & "'" & " and 注册密码 = '& Me![user_password] &" '"
改成
temp = "Select * From user Where 注册名称 = '" & Me![user_name] & "' and 注册密码 = '& Me![user_password] &"'"

还有..你能不能把me!换成别的 !也容易引起错误