Results 1 to 4 of 4
  1. #1
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544

    Question Dlookup() for NULL

    I have the below DLookup() but every time it returns null when I am sure there are records with these criteria. I have tested it without the [RecPosition] criteria and it works. What am I doing wrong here? Thanks in advance.



    Code:
    lngRecordID = DLookup("RecEmplID", "tblAuditTrail", "[RecEmplID] = " & lngEmplID & " AND [RecPosition] = ''")

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    perhaps the 'RecPosition' field is NOT a zero length string?? that's what you're asking for, in part.

    have you tried also following the 'lngEmplID' var in the watch window?? are you sure the value is what you want when the code gets here.

  3. #3
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Adam,
    checked all that. Ended up getting it to work with the following DLookup() finally...
    Code:
    lngRecordID = DLookup("RecEmplID", "tblAuditTrail", "[RecEmplID] = " & lngEmplID & " AND IsNull([RecPosition])")

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    there ya go! the record was NULL, which isn't what you were asking.

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

Similar Threads

  1. DLookup example
    By pkstormy in forum Code Repository
    Replies: 1
    Last Post: 07-16-2012, 09:52 AM
  2. DLookup
    By smidgey in forum Forms
    Replies: 13
    Last Post: 01-19-2011, 09:27 AM
  3. dlookup help
    By gsantacruz in forum Programming
    Replies: 9
    Last Post: 10-11-2010, 11:46 AM
  4. Dlookup??
    By Vikki in forum Access
    Replies: 4
    Last Post: 02-16-2010, 07:59 AM
  5. Dlookup
    By janjan_376 in forum Access
    Replies: 20
    Last Post: 07-07-2009, 07:40 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