Results 1 to 5 of 5
  1. #1
    MadTom's Avatar
    MadTom is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Location
    CT and VT
    Posts
    206

    DLookup and ELookup errors

    I my form I'm using Dlookup for a text box control source and I get an "#error" in the text box when I go to a new record.
    If I use Elookup with the same code I get "syntax error (missing operator) query expression" when I go to add new record.
    I know the problem is a Null in the data, any way to fix this problem? The easy way is to use Dlookup.
    I have searched this topic.


    Thanks,
    Tom

    Code:
    =DLookUp("[StorageType]","[tblBins]","[Bin_ID] =" & [Forms]![frmParts]![cboLocation] & "")

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Instead of DLookup, use multi-column combobox that includes related fields in RowSource. Then expression in textbox references combobox column by index, index begins with 0.

    =cboLocation.Column(1)

    Otherwise handle Null with Nz(). Is Bin_ID a number type?

    =DLookUp("[StorageType]","[tblBins]","[Bin_ID] =" & Nz([Forms]![frmParts]![cboLocation],0))
    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.

  3. #3
    MadTom's Avatar
    MadTom is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Location
    CT and VT
    Posts
    206
    Thanks! Your expression below works. StorageType is a String, Bin_ID is a Number

    =DLookUp("[StorageType]","[tblBins]","[Bin_ID] =" & Nz([Forms]![frmParts]![cboLocation],0))

    Tom

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    I still prefer combobox index method. Domain aggregate functions can be noticeably slow on forms.
    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.

  5. #5
    MadTom's Avatar
    MadTom is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Location
    CT and VT
    Posts
    206
    Ok, I'm using
    =cboLocation.Column(1) and it works fine, not sure how, will look into it.
    Thanks,
    Tom

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

Similar Threads

  1. Replies: 20
    Last Post: 02-16-2019, 07:51 AM
  2. Operator and Null errors with Dlookup
    By breezett93 in forum Access
    Replies: 14
    Last Post: 08-15-2017, 01:54 PM
  3. I need an ELookUp Example
    By BLFOSTER in forum Forms
    Replies: 16
    Last Post: 06-12-2017, 04:38 AM
  4. Error using ELookup but not DLookup
    By Rawb in forum Programming
    Replies: 12
    Last Post: 10-18-2010, 07:09 AM
  5. Replies: 3
    Last Post: 10-06-2009, 02:11 PM

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