Results 1 to 8 of 8
  1. #1
    SAM75 is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2017
    Posts
    7

    Unhappy Problem with Dlookup criteria sentence

    Dear all
    I'm trying to build a database with login form. I've made a table with employees' data as below:


    Click image for larger version. 

Name:	01.jpg 
Views:	21 
Size:	112.8 KB 
ID:	31471

    And then, I write the VBA codes for run button as below:



    Click image for larger version. 

Name:	02.jpg 
Views:	21 
Size:	116.8 KB 
ID:	31472


    But when I try to login withing the form, I receive the message which says the password is incorrect. I wonder if you can help me to correct the Dlookup criteria to match the string I enter in the form with the corresponding value in the table in strEmpPassword column.

    Thanx

    Last edited by SAM75; 11-30-2017 at 09:33 PM. Reason: Adding proper question

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,742
    Code:
    If "Me.txtPassword.Value" = Dlookup(.....
    Remove red quotes.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Also, if lngEmpID is really and Long data type, don't use apostrophe delimiters. If it is text field, why use lng prefix?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,424
    Methinks not enough. lngEmpID, which seems to be a variable holding the value EmpID from the table, looks like a number. If so, the quotes around Me.cboEmployeeID.Value would be a problem too. You don't need to specify .Value for a combo or text box - it is the default property.

    BTW, you can use either fOsUserName (Google it) or the Environ property to get the logging in user's Windows username. Then you don't need all this password stuff and people asking for a reset because they can't remember theirs. You can use these values to record who makes changes or deletions as well if that's useful, whereas a simply password function doesn't do much (and never really did). Hopefully you have at least done some things to keep users out of the tables, otherwise the password function is easy to defeat.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    As Micron said, can grab username from Windows. Suits my purposes to presume if user passes Windows Enterprise security they have authority to use the db. I have a Users table with db permissions level - some buttons or other stuff they don't need to interact with which is controlled by code. I also store their initials for auto saving into some records. A new user will see a 'registration' form the first time but once a record is in the Users table they never see that form again.
    Last edited by June7; 12-01-2017 at 01:50 AM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    SAM75 is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2017
    Posts
    7
    Thank you all for your quick response. I will try your guides ASAP.

  7. #7
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,424
    Just to clarify, I'm saying if you put their windows login name in the table they get in. If not, they don't. Some enterprises may have departments whose members need to be kept out. The self registration is a neat idea for those places where it's okay for anyone to enter.

  8. #8
    SAM75 is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2017
    Posts
    7
    Simple as this? It worked. Thank you very much
    Thank you all

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

Similar Threads

  1. Dlookup criteria
    By aceSoft in forum Access
    Replies: 3
    Last Post: 04-15-2017, 10:16 PM
  2. Replies: 2
    Last Post: 08-19-2015, 06:43 PM
  3. Querying a specific text in a sentence
    By scorpion99 in forum Queries
    Replies: 1
    Last Post: 10-13-2014, 12:39 AM
  4. Replies: 2
    Last Post: 04-11-2013, 06:36 PM
  5. dlookup with a contains criteria?
    By noretoc in forum Access
    Replies: 3
    Last Post: 05-02-2012, 10:18 AM

Tags for this Thread

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