Access 2007
log in form - ado connection to SQL2005
trying to see if user is in table and if match then open form if not after 3 times exit app
Using a WHERE statement but I am not getting any error if user does not match
Private Sub cmdLogIn_Click()
'Check to see if data is entered into the uer id box
If IsNull(Me.txtLogInUser) Or Me.txtLogInUser = "" Then
MsgBox "You must enter your User Name.", vbOKOnly, "Required Data"
Me.txtLogInUser.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtLogInPassword) Or Me.txtLogInPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtLogInPassword.SetFocus
Exit Sub
End If
Dim strLogInUser As String
If txtLogInUser.Visible = True Then
Me.txtLogInUser.SetFocus
strLogInUser = Me.txtLogInUser.Text
Dim strLogInPassword As String
If txtLogInPassword.Visible = True Then
Me.txtLogInPassword.SetFocus
strLogInPassword = Me.txtLogInPassword.Text
Else
End If
'Check value of password in tblEmployees to see if this
'matches value chosen in combo box
'Dim strSQL As String
Dim strSQLLogOn As String
Dim adoLogInConnection As ADODB.Connection
Dim adoLogInRecordset As ADODB.Recordset
Set adoLogInConnection = New ADODB.Connection
Set adoLogInRecordset = New ADODB.Recordset
Dim pw As String
pw = "xxxxxxxx"
adoLogInConnection.Open "Driver={SQL Server};" & _
"Server=serverName;" & _
"DataBase=myDatabase;" & _
"User ID=UserID;" & _
"Password=" & pw
adoLogInRecordset.CursorType = adOpenKeyset
adoLogInRecordset.LockType = adLockOptimistic
adoLogInRecordset.Open "tblUserList", adoLogInConnection, , , adCmdTable
strSQL = "Select tblUserList.[fldUserFirst], tblUserList.[fldUserLast] " & _
"From tblUserList " & _
"Where tblUserList.[fldUser] ='" & strLogInUser & "';"
MsgBox ("User '" & strLogInUser & "' is logged on now!")
procLogUser ' procedure writes username and time stamp to server table
'Close logon form and open splash screen
DoCmd.Close acForm, "frmLogIn", acSaveNo
DoCmd.OpenForm "frmWork" 'for now open to frmWork during testing
adoLogInRecordset.Close
adoLogInConnection.Close
Set adoLogInRecordset = Nothing
Set adoLogInConnection = Nothing
End Sub
I do have procedure to write to log in table - it is working properly at this time