Results 1 to 5 of 5
  1. #1
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496

    dlookup() syntax

    I've got this line of code, which is not good; I may be to close to it, as I an't find the problem. ... another set of eyes would help (please ?)



    --------------------------
    vcost = nz(DLookup("[amount]", [FixtureCatalogueCostHistory], [Manufacturer] = "'" & Me.Manufacturer & "' " & _
    "and " & _
    [CatalogNumber] = "'" & Me.CatalogNo & "'"),"")
    --------------------------

    all fields and table names are correct
    [amount] is currency
    [manufacturer] and [CatalogNumber] are text

    the fields on my form: Me.Manufacturer and Me.CatalogNo are correct

    many thanks in advance,
    mark

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    in a query, the general syntax for domain functions is:
    Code:
    Dfunction("[field]", "table", "criteria")
    in code it's a bit different:
    Code:
    Dfunction("field", "table", "criteria")
    The criteria section gives problems too. You are specifically missing some quotes and the brackets I think also need to be taken out. E.G. -
    Code:
    vcost = nz(
    
    DLookup("amount", "FixtureCatalogueCostHistory", 
    
    "[Manufacturer] = '" & Me.Manufacturer & "'" & _
    
    " and " & _
    
    "[CatalogNumber] = '" & Me.CatalogNo & "'"), 0)
    Also not sure if the lookup function is compatible with NULLS. You might have to use iif(iserror()) as a substitute but I doubt it.

  3. #3
    jzwp11 is offline VIP
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    oops, I see Adam got in ahead of me...

    You might try this:

    Code:
    vcost = nz(DLookup("[amount]", "[FixtureCatalogueCostHistory]", "[Manufacturer] = '" & Me.Manufacturer & "' and [CatalogNumber] = '" & Me.CatalogNo & "'"),"")

  4. #4
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    please mark it as solved if this solved you problem.

  5. #5
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    perfect.. thanks

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

Similar Threads

  1. Syntax Contains Problem
    By pimlicosnail in forum Forms
    Replies: 9
    Last Post: 02-18-2010, 12:16 PM
  2. Syntax Error
    By KLynch0803 in forum Programming
    Replies: 11
    Last Post: 02-04-2010, 01:45 AM
  3. if or syntax help needed
    By techexpressinc in forum Queries
    Replies: 16
    Last Post: 01-11-2010, 08:03 AM
  4. Sql Syntax Query
    By Matthieu in forum Queries
    Replies: 4
    Last Post: 12-30-2009, 09:41 AM
  5. Looping syntax
    By fadiaccess in forum Access
    Replies: 1
    Last Post: 10-23-2009, 02:57 AM

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