Login Form - VB6 & Access Database
Posted on 2003-03-14
I was wondering if anyone could help me with this seemingly easy problem.
I am creating a log in form for an application, which the user puts their employee no. in txtempno field, and password in txtpassword field. After clicking the cmdlogin button, the application should look at the database table and find the employee whose employee no matches the value of txtempno, then see if the password matches.
The problem I'm having with it is I keep getting a "Syntax error in FROM clause" statement. I have tried every possible combination of apostrophes, but all to no avail!
Please could someone help me figure out this seemingly simple, yet frustrating query!
The code I have written is below, any questions, feel free to ask.
Thanks a bunch,
Private Sub cmdlogin_Click()
Dim db As New ADODB.Connection
Dim rs As ADODB.Recordset
Dim pw As String
pw = txtempno
db.Open "provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=R:\Dissertation Files\Data Base\a97DBase.mdb;"
Set rs = db.Execute("select * from Password where Employee_No = '" & txtempno & "'")
If rs!Password <> txtpassword Then
MsgBox "Wrong Password. Please enter again", vbOKOnly, "Log In"