Results 1 to 7 of 7
  1. #1
    Join Date
    May 2014
    Posts
    98

    Red face Unanswered: Error 13 Type Mismatch

    HI I have a login form on which I have an Ok button and what I am trying to do is match the user ID on the login form with the User ID in the tblUser. and also Password on the login form with Password in the table. If both matches I am trying to make few fields visible to few people. But I am getting Error 13 Type Mismatch.

    Here is my code
    Private Sub cmd_Ok_Click()
    'Check that EE is selected
    If IsNull(Me.cboUser) Then
    MsgBox "You need to select a user!", vbCritical
    Me.cboUser.SetFocus
    Else
    'Check for correct password
    If Me.txtPassword = Me.cboUser.column(2) Then
    'Check if password needs to be reset
    If Me.cboUser.column(3) = True Then
    DoCmd.OpenForm "frmPasswordChange", , , "[UserID] = " & Me.cboUser
    End If
    DoCmd.OpenForm "frmHomePage"
    Me.Visible = False
    Dim X As Integer
    X = Nz(DLookup("UserID", "tblUser", "UserID='" & cboUser.column(0) & "'" And "Password='" & txtPassword & "'"))
    If X = 57 Then
    Forms!Formname!comboname.Visible = False
    Else
    MsgBox "Password does not match, please re-enter!", vboOkOnly
    Me.txtPassword = Null
    Me.txtPassword.SetFocus
    End If
    End If
    End If

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    On which line?
    Have a nice day!

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I'd put money on it being:-
    If Me.txtPassword = Me.cboUser.column(2) Then
    instead of
    If Me.txtPassword.text = Me.cboUser.column(2) Then

    althoughit never ceases to amaze me that people roll their own password / user authentication processes when the API call does it all for you
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    May 2014
    Posts
    98

    error 13 type mismatch

    X = Nz(DLookup("UserID", "tblUser", "UserID='" & cboUser.column(0) & "'" And "Password='" & txtPassword & "'"))

  5. #5
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    It should be:
    Code:
    X = Nz(DLookup("UserID", "tblUser", "UserID='" & cboUser.column(0) & "' And  Password='" & txtPassword & "'"))
    Have a nice day!

  6. #6
    Join Date
    May 2014
    Posts
    98

    error 13 type mismatch

    I am still getting the same error

  7. #7
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    ok so when the code breaks go through each eleemntn and make certaint here are sane values

    in the intermediate window you cna see the values of variables by prefixing the variable with a ?
    eg to see the parameters you are supplying
    ?"UserID='" & cboUser.column(0) & "' And Password='" & txtPassword & "'"

    Id suggest you do that and make certain the values are 'sane'
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •