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!

HI,
what error u r receiving there...?

-Venkat

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...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.