Results 1 to 6 of 6
  1. #1
    jj1 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    128

    Unhappy 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
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    The usu. means your doing something with text when it should be a number. (or vise versa)
    maybe at: "[UserID] = " & Me.cboUser

    if userID are strings like "bSmith" , then the code would need quotes: "[UserID] = '" & Me.cboUser & "'"

  3. #3
    jj1 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    128
    Thanks for the reply I just want to mention that the code is breaking at

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

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    It could be X is defined wrong...but in this case..I would use this if anything can be null...
    (concat an empty string at the end...this way nulls cant crash it)

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

  5. #5
    jj1 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    128
    No it still didn't worked

  6. #6
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    Did you fix: DoCmd.OpenForm "frmPasswordChange", , , "[UserID] = " & Me.cboUser
    quotes missing.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. error 13 type mismatch
    By jkd in forum Programming
    Replies: 2
    Last Post: 04-19-2014, 09:46 PM
  2. Replies: 7
    Last Post: 07-24-2013, 02:01 PM
  3. type mismatch error 13
    By Compufreak in forum Access
    Replies: 3
    Last Post: 08-10-2012, 03:48 AM
  4. Replies: 1
    Last Post: 05-11-2012, 10:59 AM
  5. Error#13 Type Mismatch
    By Nistin27 in forum Access
    Replies: 8
    Last Post: 08-17-2011, 04:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums