Why do i get Type Mistmatch ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • k35hav
    New Member
    • Aug 2008
    • 2

    #1

    Why do i get Type Mistmatch ?

    I have created a form for the user to enter password before accessing the system
    The table password has been created with the field uname of type Text and pword of type Text. The uname is displayed as a combo box on the form. When I enter the password and click ok it says Type Mismatch (Error 13)

    Here is the code:

    Option Compare Database

    Private Sub Form_Open(Cance l As Integer)
    DoCmd.Maximize

    uname.SetFocus
    End Sub

    Private Sub cmd_close_Click ()
    DoCmd.close
    End Sub

    Private Sub ok_Click()
    Dim rcd As Recordset
    Set dbs = CurrentDb
    If (IsNull(uname) Or Len(Trim(uname) ) = 0) Then
    s = MsgBox("Please check that you have entered your username!")

    Else
    If (IsNull(pword) Or Len(Trim(pword) ) = 0) Then
    s = MsgBox("Please check that you have entered your password!")

    Else
    Set rcd = dbs.OpenRecords et("select pword from password where uname='" + Me.uname + "'")

    If rcd!pword = Me.pword Then
    DoCmd.close
    DoCmd.OpenForm "mainmenu"
    Else
    DoCmd.Beep
    bool = MsgBox("Invalid password! Try again please")
    pword = " "
    pword.SetFocus
    End If
    End If
    End If
    End Sub



    Thnks for your help :)
  • hjozinovic
    New Member
    • Oct 2007
    • 167

    #2
    which Access version do you have?
    In Access 2003 you can go to Tools->Security...
    [HTML]Make password-protected database
    Create .mdw file with users/user groups
    Join the database to the .mdw file[/HTML]

    This is probably far better than the solution you are trying to use.
    Also it's possible to use .mdw file with Acc2007.

    I suggest you try reading help on security, user and group accounts etc.

    Comment

    • k35hav
      New Member
      • Aug 2008
      • 2

      #3
      Originally posted by hjozinovic
      which Access version do you have?
      In Access 2003 you can go to Tools->Security...
      [HTML]Make password-protected database
      Create .mdw file with users/user groups
      Join the database to the .mdw file[/HTML]

      This is probably far better than the solution you are trying to use.
      Also it's possible to use .mdw file with Acc2007.

      I suggest you try reading help on security, user and group accounts etc.
      Well..first of all thank you for your reply :)
      i wanted to create that form as it shall have different users. Thus preventing some users to access some forms..
      I dont think that the password wizard in access can help me out..
      The database is in 2002 format
      can you help?

      Comment

      • missinglinq
        Recognized Expert Specialist
        • Nov 2006
        • 3533

        #4
        Set rcd = dbs.OpenRecords et("select pword from password where uname='" + Me.uname + "'")

        I think Access is popping a Type Mismatch error because it sees you as trying to add your uname and quotation marks! You're using plus signs (+) for your concatenation, and you should be using the ampersand (&) sign instead.

        Welcome to Bytes!

        Linq ;0)>

        Comment

        Working...