Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21090

"syntax error in where clause" - please help

$
0
0
Hi, please help me on the below code, i am new at VB.

Name:  Untitled.jpg
Views: 129
Size:  26.9 KB

Code:

Private Sub cmdOK_Click()
Dim sqlPassword As String
Dim rstPassword As ADODB.Recordset
Dim intDaysLeft As Integer
Dim dateHolder As Date
Dim strChngPassAnsw As String
Dim varBK As Variant

Set cnn = New ADODB.Connection
Set rstPassword = New ADODB.Recordset
cnnOpen
'Open up the database and search for username and password
sqlPassword = "Select * from tblEmployee where "
rstPassword.Open sqlPassword, cnn, adOpenKeyset, adLockPessimistic

With rstPassword
varBK = rstPassword.Bookmark
.Find "empusername = '" & txtUserName.Text & "'", , adSearchForward, 1
    If Not .EOF Then
        If .Fields("EmpPassword") = txtPassword.Text Then
                If .Fields("EmpPassword") = "123456" Then 'If the default pswd then force them to change it
                changepass = True
                End If
            dateHolder = FormatDateTime(.Fields("pswddate"), vbShortDate)
            Me.Hide
        Else
            'Wrong Password
            MsgBox "Invalid Password, try again!", , "Login"
            txtPassword.Text = ""
            txtPassword.SetFocus
            Exit Sub
        End If
    Else
        'Wrong User Name
        MsgBox "Invalid User Name, try again!", , "Login"
        txtPassword.Text = ""
        txtUserName = ""
        txtUserName.SetFocus
        Exit Sub
    End If
    ' Global variables to hold User's data for permissions
    EmpCurrent.emUserName = .Fields("EmpUserName")
    EmpCurrent.emDept = .Fields("EmpDeptID")
    EmpCurrent.emFirstName = .Fields("EmpFirst")
    EmpCurrent.emLastName = .Fields("EmpLast")
    EmpCurrent.emGrade = .Fields("EmpGradeID")
    EmpCurrent.emID = .Fields("EmployeeID")
    EmpCurrent.empswd = .Fields("EmpPassword")
    ' Check the date and force a change every 90 days
    intDaysLeft = Date - dateHolder
    If intDaysLeft >= 85 Then
    intDaysLeft = 90 - intDaysLeft
        If intDaysLeft <= 0 Then
        MsgBox "Your Password is expired, please change it now.", , "Password Expired"
        changepass = True
        Else
        strChngPassAnsw = MsgBox("Your password expires in " & intDaysLeft & "days." & vbNewLine & _
        "Would you like to change it now?", vbYesNo, "Password Expiration")
            If strChngPassAnsw = vbYes Then
            changepass = True
            End If
        End If
    End If
End With
rstPassword.Close
Set rstPassword = Nothing
cnnClose
End Sub

Attached Images
 

Viewing all articles
Browse latest Browse all 21090

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>