terjr
asked on
MS Access Log On form
I am using a table named "Users" to store authorized users of the database. It has two fields named "UserName" and "UserPassword". I have constructed a simple LogOn form with two text fields named "MyUserName" and "MyPassword". The LogOn form also has an "OK" button and a "Cancel" button. I am using the following code in conjunction with the OnClick function for the "OK" button and I am getting a syntax error in the FROM clause. Please assist.
Dim rs As Recordset
Set rs = CurrentDb().OpenRecordset( "SELECT Users.* FROM Users" & "WHERE(((Users.UserName)=" "&Me.MyUse rName&"") AND ((Users.UserPassword)=""&M e.MyPasswo rd&"")));" )
If rs.Recordset = 0 Then
Beep
MsgBox "Invalid User Name or Password"
RS.Close
Exit Sub
Else
Open Main switchboard
End If
rs.Close
Dim rs As Recordset
Set rs = CurrentDb().OpenRecordset(
If rs.Recordset = 0 Then
Beep
MsgBox "Invalid User Name or Password"
RS.Close
Exit Sub
Else
Open Main switchboard
End If
rs.Close
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I changed to the code above and now I get a "type mismatch" error.
what is the field type for UserName and Password?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
both are text fields
ASKER
The Reference is grayed out
Click the square button to reset the codes or stop. then tools>references
Actually it is {USER} not {USERS} is the reserved word for access and jet 4.
rey;-)