0

please help me out in wat could be the error in the below code as it is not running when it comes down to the openrecordset statement!

Private Sub cmdOK_Click()
Dim rst As DAO.Recordset
    'check for null password
    If IsNull(Trim(userid)) Then
        MsgBox "User Name required.", vbExclamation
        userid.SetFocus
        Exit Sub
    End If
    
    'check for null password
    If IsNull(Trim(pswd)) Then
        MsgBox "Password required.", vbExclamation
        pswd.SetFocus
        Exit Sub
    End If
    
    
    Dim tempRecordSet As Recordset
    Dim Password As String
    
    Set tempRecordSet = rst.OpenRecordset("select * from Login where userid = '" & userid.Text & "'")
    
    If tempRecordSet.RecordCount <> 0 Then
        Password = UCase(Trim(tempRecordSet("Password")))
    End If
    
 
    tempRecordSet.Close
    Set tempRecordSet = Nothing
    
    If Password <> UCase(Trim(pswd)) Then
       MsgBox "Incorrect password", vbExclamation
    Else
     
        MsgBox "Congratulations! Right Password!!!", vbExclamation
    End If
    pswd = Empty
End Sub

thankx a lot! please help as soon as possible!

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by smile4evr
0

the right code is

Private Sub cmdOK_Click()
Set rstSchema = New adodb.Recordset
rstSchema.Open "select count(*) from Login where userid = '" & userid.Text & "' and pswd = '" & pswd.Text & "'", CN1, adOpenDynamic, adLockOptimistic
If rstSchema(0) = 0 Then
MsgBox "Check User Name & Password"
userid.Text = ""
pswd.Text = ""
Else
If rstSchema(0) = 1 Then
frmPast.Show
Unload Me
End If
End If
End Sub

...
take care...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.