Results 1 to 12 of 12
  1. #1
    rafal is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2010
    Posts
    4

    Login form type mismatch

    Hey,


    could someone correct my mistake in this code?

    Description

    - Form ekran_uzytkownika uses table which contains columns : pesel (as double) and haslo (as string)
    - when I use only " "[pesel]=" & login " it works well but when I add any other condition I get error 13
    - condition " "[haslo]=" & haslo " doesn't really work, it prompts me to type it twice as it couldn't recognize [haslo] column.

    Private Sub loguj_Click()
    Dim login As Double
    Dim haslo As String
    Me.te_PESEL.SetFocus
    login = Val(Me.te_PESEL.Text)
    Me.te_haslo.SetFocus
    haslo = Me.te_haslo.Text

    DoCmd.OpenForm "ekran_uzytkownika", , , ("[pesel]=" & login) And ("[haslo]=" & haslo) ' error 13 '
    End Sub
    Peace

    Solution
    when I use only " "[pesel]=" & login " it works well but when I add any other condition I get error 13
    DoCmd.OpenForm "ekran_uzytkownika", , , "[pesel]=" & login & " And [haslo]='" & haslo & "'"

    condition " "[haslo]=" & haslo " doesn't really work, it prompts me to type it twice as it couldn't recognize [haslo] column.
    Added hidden field with password on ekran_uzytkownika form. (Not safe but it doesn't have to be in this case )
    Last edited by rafal; 12-24-2010 at 11:32 AM.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    You didn't restart the string properly. Try this:

    DoCmd.OpenForm "ekran_uzytkownika", , , "[pesel]=" & login & " And [haslo]='" & haslo & "'"

    You can get rid of the setfocus lines if you drop the ".Text" from the other lines. .Value is the default, and it's what you want anyway.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    This line:
    DoCmd.OpenForm "ekran_uzytkownika", , , ("[pesel]=" & login) And ("[haslo]=" & haslo) '
    ...should read:
    DoCmd.OpenForm "ekran_uzytkownika", , , "[pesel]=" & login & " And [haslo]='" & haslo & "'"

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    That Paul just types too fast!

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    I tell ya, it's the lower altitude. More oxygen to the fingers.

    You've got a bonus double quote in there by the way (after And).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    No extra charge for the extra quote. Thanks.

  7. #7
    rafal is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2010
    Posts
    4
    Thanks

    only problem is that it compares password given in textbox to password taken from popup window instead comparing it to password in table.

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Your OpenForm command is simply putting a WhereCondition on the RecordSource of the ekran_uzytkownika form. Not the usual way to supply a password.

  9. #9
    rafal is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2010
    Posts
    4
    Silly me, fixed. Thanks again
    Solved

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Glad to hear you got it sorted. Care to share your solution with others that read this thread?

  11. #11
    rafal is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2010
    Posts
    4
    Added solution to my first post

  12. #12
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by rafal View Post
    Added solution to my first post
    Thank you.

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

Similar Threads

  1. type mismatch in expression
    By lilg1924 in forum Database Design
    Replies: 3
    Last Post: 10-06-2010, 01:37 AM
  2. Type mismatch
    By jgelpi16 in forum Programming
    Replies: 1
    Last Post: 08-07-2010, 06:54 AM
  3. data type mismatch
    By jgelpi16 in forum Programming
    Replies: 5
    Last Post: 08-02-2010, 04:15 PM
  4. Type Mismatch - HELP!
    By jgelpi in forum Programming
    Replies: 3
    Last Post: 07-17-2009, 03:53 PM
  5. Replies: 4
    Last Post: 05-16-2009, 09:17 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