Results 1 to 12 of 12
  1. #1
    Join Date
    Feb 2014
    Posts
    14

    Question Unanswered: how to write (Dlookup) with multi criteria

    hello every body
    i have problem with (Dlookup) function
    i create user name and password form and its work correctly with password
    (chick only password )
    that is mean :
    if i have
    user name (alanssari) password (123456) do command open report
    and
    user name (alaa) password (147258) do command open form
    when i inter in user name (alanssari) and password (147258) do command open form
    how i can check user name and password both in same time
    please see my code in attach
    Attached Thumbnails Attached Thumbnails 1.png   2.png   3.png   4.png  

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    See if the example at the bottom gets you started:

    General: DLookup Usage Samples
    Paul

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    in place of the !
    separate the two clasues using AND
    ...& AND tmpuserid = 'admin'
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Feb 2014
    Posts
    14
    Thank you 'pbaldy and healdem'
    pbaldy I try the way in example but doesn't work I use this code

    Nz(DLookUp("[UserID]","tblUsers","[Password]='" & [txtPassword] & "'"_ "[UserName]='" & [cboUser] & "'"),-1)

    this code didn't work can you help me please ?
    if you can write the correct code
    thank you so much

  5. #5
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Nz(DLookUp("[UserID]","tblUsers","[Password]='" & [txtPassword] & "' And [UserName]='" & [cboUser] & "'"),-1)

  6. #6
    Join Date
    Feb 2014
    Posts
    14
    thank you so much pbaldy
    but this code not work too ?!!
    Last edited by alanssari; 03-08-14 at 13:58.

  7. #7
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Nz(DLookUp("[UserID]","tblUsers","[Password]='" & [txtPassword] & "' And [UserName]='" & [cboUser] & "'"),FALSE)

    replace the following
    userid should be the name of a column in your table
    tblusers should be the name of the table
    password should be the name of the column containing the password
    txtPassword shoudl be the name tof the control containing your password
    UserName sgouyld be th ename of the column containing the user name
    cboUser should be the name of the control containing the user name

    mind you if it were me I'd just pull the network logon from using an API call and use that network logon to authenticate
    I'd rather be riding on the Tiger 800 or the Norton

  8. #8
    Join Date
    Feb 2014
    Posts
    14
    thank you so much healdem
    but this code not work too ?!
    I tried to upload my data base but its so heavy
    Last edited by alanssari; 03-08-14 at 15:20.

  9. #9
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    actually I'd strongly recommend you ditch this whole process
    use the API call to get a userid
    #then look for that user in your table. you dont' need to authenitcate a password as its done at network level
    I'd rather be riding on the Tiger 800 or the Norton

  10. #10
    Join Date
    Feb 2014
    Posts
    14
    thank you so much about your answer but I didn't the way to do that u am just a beginner in access
    so if you can help I well stay thank you

  11. #11
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    for now lets assume
    DLookUp("[UserID]","tblUsers","[Password]='" & "mypassword" & "' And [UserName]='" & "alanssari" & "'")

    replace mypassword with your actual password and alanssari with the actual username
    both the user name and password supplied must pre exists in the table

    ..all we are trying to do is prove the dlookup works. once you have got passed the hurlde of making the dlookup work then you can refien it.

    'it doesnt' work' is inadequate to help fix problems remotely

    it cilukd be a data problem
    it coudl be you are using the values you think you are
    it could be a whole range of problems

    once you have proved its working then you can twek things to make certain they work

    however its going to be tough as you insist on using macros.... something very few of the reposndents here use. for me they are clunky and hgard to debug, not immedaitely transparent as to what they are doing so I don't use macro's (unless I have to. anything yhou can do in a macro you can do in VBA and VBA is mush much easier to debug
    I'd rather be riding on the Tiger 800 or the Norton

  12. #12
    Join Date
    Feb 2014
    Posts
    14
    thank you so much (healdem) you help me a lot thanks for your time
    i well try to do that
    best regards

Posting Permissions

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