There are four core objects in the form - txtUserName, txtPassword, cmdOK and cmdCancel. A database named LoginY2K.mdb is connected to this form. It contains a table named User which comprising UserName and Pasword two fields. Below is the coding:

option Explicit
public LoginSucceeded as Boolean
---------------------------------------------------------------
private Sub cmdCancel_Click()
'set the global var to false
'to denote a failed login
LoginSucceeded = false
End
End Sub
---------------------------------------------------------------
private Sub cmdOK_Click()
Dim conAdo as ADODB.Connection
Dim rstAdo as ADODB.Recordset

set conAdo = new ADODB.Connection
set rstAdo = new ADODB.Recordset
conAdo.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Login Security\LoginY2K.mdb;Persist Security Info=false"
rstAdo.Open "Select * From User Where UserName = '" & txtUserName.Text & "';", conAdo, adOpenStatic, adLockOptimistic, adCmdText 'error OCCURS HERE !!!

MsgBox rstAdo.RecordCount & "found." 'Just to test
'check for correct password
If txtPassword .txt= rstAdo.Fields("Password") then
'place code to here to pass the
'success to the calling sub
'setting a global var is the easiest
LoginSucceeded = true
MsgBox "U r here" ' Just to test
else
MsgBox "Invalid Password, try again!", , "Login"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
End If
End Sub



But an error pops up saying," Run-time error '-2147217900 (8004e14); Syntax error in FROM clause. " after submitting the user name and password. (pls look at ERROR OCCURS HERE)

Can anyone help me???