Results 1 to 5 of 5
  1. #1
    mloucel's Avatar
    mloucel is offline Novice
    Windows 11 Office 365
    Join Date
    Sep 2023
    Location
    Anaheim, CA
    Posts
    1

    Post Help NEWBIE here with DLookUp

    I am a bit new with VBA and I cannot find a way to get this right.

    On a form I have 3 records that I Input

    FirstName LastName and DateOfBirth

    I need to create a dlookup to search for the 3 of them from a table

    Yes I am lost, specially on the Date.

    FN and LN and DOB are sourced directly to the Table.



    I am creating a NEW record and I am trying to dlookup those 3 values if they exist in my table.

    Thanks for your help.

    Maurice.

  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,530
    See if this helps, noting the multi-criteria example at the end:

    http://www.theaccessweb.com/general/gen0018.htm

    Welcome to the site by the way, from west of you in Nevada.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,012
    Put the criteria into a string variable.
    Debug.print it until you get it correct
    Then use that in the function.

    Date will need to be in mm/dd/yyyy format, but as you are in the USA, that should not be a problem for you.
    You can use yyyy-mm-dd also, but it is your country format, so need really, unless you prefer that format?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    233
    Show us what you tried.

    If you need this to check if a record with that data already exists, you might also consider creating a unique index on the three fields together. Then it is impossible to create duplicate records and you do not have to use VBA.
    Groeten,

    Peter

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,967
    Unique index on name fields would prevent multiple people who have same name. Sure, it would be rare in same dataset but not impossible. Names are poor unique identifiers.
    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.

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

Similar Threads

  1. Replies: 4
    Last Post: 08-13-2012, 04:39 PM
  2. Newbie. DLookup gives type mismatch error.
    By graffiti in forum Programming
    Replies: 4
    Last Post: 12-13-2011, 05:22 AM
  3. Newbie. How do I use DLookup with a variable please?
    By graffiti in forum Programming
    Replies: 2
    Last Post: 12-12-2011, 08:59 AM
  4. Form Design Question with DLookup (newbie)
    By wongc61 in forum Access
    Replies: 4
    Last Post: 07-08-2011, 03:22 PM
  5. Newbie Dlookup problem
    By opopanax666 in forum Programming
    Replies: 7
    Last Post: 08-13-2010, 05:47 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