Am running the code below to create user login form.type mismatch error occur why?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Evelyne
    New Member
    • Feb 2011
    • 2

    Am running the code below to create user login form.type mismatch error occur why?

    Private Sub cmdOK_Click()

    Dim cn As New ADODB.Connectio n
    Dim obj As New ADODB.Command
    Dim rst As New ADODB.Recordset

    On Error GoTo Err_Handler

    Set cn = CurrentProject. Connection

    With obj
    .ActiveConnecti on = cn
    .CommandText = "LogComparePass word"
    .CommandType = adCmdStoredProc
    End With

    'validate the username and password

    If Me.txtuserName <> Me.txtuserName Then
    MsgBox "Incorrect username.", vbInformation, "username"
    Me.txtuserName. SetFocus
    Exit Sub
    ElseIf Me.TxtUserPwd <> Me.TxtUserPwd Then
    MsgBox "Incorrect password.", vbInformation, "password"
    Me.TxtUserPwd.S etFocus
    Exit Sub


    Else

    obj(1) = Me.txtuserName
    obj(2) = Me.TxtUserPwd

    obj.Execute

    'Set rst = obj.Execute

    'Me.TxtUserPwd = rst!UserPasswor d

    End If


    Err_Exit:
    Exit Sub
    Err_Handler:
    MsgBox Err.Number & " " & Err.Description , vbInformation, "Error"
    Resume Err_Exit

    Unload Me


    End Sub
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1290

    #2
    You don't say where the mismatch error occurs. Change your Resume Err_exit to Resume next and monitor the code to see which instruction caused the problem.

    Possibly it was one of these two
    obj(1) = Me.txtuserName
    obj(2) = Me.TxtUserPwd

    I see that obj is dimmed as New ADODB.Command. I've never use a .Command construction but I'm wondering what the type of (1) and (2) are. Is the mismatch that you are putting text data into non-text parameters?

    Jim

    Comment

    Working...