Results 1 to 5 of 5
  1. #1
    Deggsy is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    May 2015
    Posts
    20

    Simple DLookup Question


    Maybe I'm having a brainfreeze (Maybe? LOL), but can anyone explain to me what this DLookup will do:

    Code:
    =DLookUp("[Location Name]","Del_PostCode","[Employee Number] =" & [Forms]![Course Booking]![Employee Number])
    In the course booking form where it sits, it should bring up the store location connected with the employee number, and it works for most of the employee numbers entered, but some of the records aren't showing the location details, and I'm trying to determine if the fault lies with the form or with the records (I'm assuming the records, as like I said it does work for many examples, just a few)

  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,652
    I would agree that it's something with the records, given that it works for many. See if there is a record to find for an employee number that fails. Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    If you still need an answer as to what the lookup is doing, howboutdis:
    look in field [Location Name] in table [Del_Postcode] and retrieve the value in [Location Name] where the [Employee Number] equals the value in the Employee Number control on the Course Booking form.

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    My guess would be that the table Del_Postcode is missing entries for some employees, so you won't get a location for employee number that are on your form, but have no matching record in Del_Postcode. The DLookup returns a Null, but assigning a Null to a form field causes no problems.

    Try this:

    =Nz(DLookUp("[Location Name]","Del_PostCode","[Employee Number] =" & [Forms]![Course Booking]![Employee Number]),"No location found")

  5. #5
    Deggsy is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    May 2015
    Posts
    20
    Quote Originally Posted by John_G View Post
    My guess would be that the table Del_Postcode is missing entries for some employees, so you won't get a location for employee number that are on your form, but have no matching record in Del_Postcode. The DLookup returns a Null, but assigning a Null to a form field causes no problems.

    Try this:

    =Nz(DLookUp("[Location Name]","Del_PostCode","[Employee Number] =" & [Forms]![Course Booking]![Employee Number]),"No location found")
    Thanks - I suspected it was due to missing entries for new employees, so I'll give this a try :-)

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

Similar Threads

  1. Issue with seemingly simple DLookUp()
    By steezy in forum Forms
    Replies: 6
    Last Post: 10-22-2014, 02:09 PM
  2. Semi-Nube Simple DLookup Issue - Help?
    By bimcompu in forum Programming
    Replies: 5
    Last Post: 07-26-2013, 07:21 AM
  3. Simple question
    By M.West in forum Database Design
    Replies: 2
    Last Post: 08-16-2012, 12:41 AM
  4. Help With Simple Error on Dlookup and Insert To
    By asdaf3814 in forum Programming
    Replies: 9
    Last Post: 08-09-2012, 10:50 AM
  5. Simple question?
    By roads.zx in forum Access
    Replies: 0
    Last Post: 10-15-2009, 04:56 PM

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