Results 1 to 4 of 4
  1. #1
    kattatonic1 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Location
    Toronto, Canada
    Posts
    77

    DLookup syntax

    I'm having a syntax error trying to get a value into a textbox on a form.

    This is what I think should work:


    =DLookUp([Input Constants]![Value],[Input Constants],[Input Constants]![Constant]='Test')

    [Input Constants] is my table
    [Value] is field that contains the number I wish to return; it is a number field
    [Constant] is the field for the criteria test; it is text

    I've tried what seems every syntax permutation but I continue to get #Name? or a blank returned.

    Please help.

    Kay
    from Toronto

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    The arguments must be within quotes.

    =DLookUp("[Value]", "[Input Constants]", "[Constant]='Test'")

    If you want the criteria to be dynamic by reference to another field or control, concatenate the variable.

    =DLookUp("[Value]", "[Input Constants]", "[Constant]='" & [controlname here] & "'")

    Access Help has more info on using domain aggregate functions. However, these functions can perform slowly in queries, forms, reports. There are options that work better. Just depends on your data and form design.


    NOTE: I split your post to a new thread. Thread hijacking is discouraged. If you want your question to receive maximum attention, start a new thread and reference the old thread if you think it helps explain yours.
    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
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Techonthenet has all sorts of syntax and examples of Access functions.
    http://www.techonthenet.com/access/f...in/dlookup.php

  4. #4
    kattatonic1 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Location
    Toronto, Canada
    Posts
    77
    Thank you, June7! I tried quotes but I think I had the last expression as "[Constant]"='Test'). Now I see the point of "[Constant]='Test'"). I'll also use the dynamic technique in this database; I'm sure!

    So regarding the thread-jacking, I thought keeping similar questions together was useful but I see what you mean! Sorry to cause you work.

    orange -- Nice reference page, thanks! I will use that too.

    Kay
    from Toronto

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

Similar Threads

  1. dlookup syntax
    By markjkubicki in forum Access
    Replies: 3
    Last Post: 06-25-2014, 06:13 PM
  2. Dlookup syntax
    By crowegreg in forum Programming
    Replies: 2
    Last Post: 03-05-2014, 06:00 PM
  3. IIf and dlookup syntax
    By AndycompanyZ in forum Forms
    Replies: 3
    Last Post: 06-28-2011, 02:47 PM
  4. DLookup() syntax????
    By jgelpi16 in forum Programming
    Replies: 3
    Last Post: 03-30-2011, 09:14 AM
  5. dlookup() syntax
    By markjkubicki in forum Programming
    Replies: 4
    Last Post: 08-24-2010, 12:31 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