Results 1 to 6 of 6
  1. #1
    ladiross is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    3

    problem dlookup

    Hello,


    I have used a DLookup in a calculated field in a query. but i Have an wrong result.
    the query is:

    GRAMMI_CAL: DLookUp("[GRAMMATURA]";"GRAMMATURA";"[COD_PRODOTTO]= '" & [FORMS]![SCHEDA GIORNALIERA]![PRODOTTO] & "'" And "[COMMESSA]= '" & [FORMS]![SCHEDA GIORNALIERA]![COMMESSA] & "'")

    why?

  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    You haven't given us anywhere near enough information to answer your question. The syntax of the DLookup seems to be OK, but beyond that, we can only guess.

    What does "wrong result" mean?

    It could be:

    - Dlookup returns the wrong field
    - where clause in the dlookup is wrong
    - dlookup references the wrong form fields
    - form data does not match any table data
    - something else.....

    Please give more information

  3. #3
    ladiross is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    3
    dlookup returns a wrong value. for example:

    Mozzarella, TORINO, 5
    LATTE, BARI, 10

    IF DLOOKUP HAVE (MOZZARELLA, TORINO) AS PARAMETRES, IT RETURNS 10 (NOT 5!).

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Your DLookup has bad quote marks as shown in red. Remove them.

    GRAMMI_CAL: DLookUp("[GRAMMATURA]";"GRAMMATURA";"[COD_PRODOTTO]= '" & [FORMS]![SCHEDA GIORNALIERA]![PRODOTTO] & "'" And "[COMMESSA]= '" & [FORMS]![SCHEDA GIORNALIERA]![COMMESSA] & "'")

    Try to avoid field and table names that are same. Common convention is to use plurals for table names.

    Title case is easier to read than all upper case. Also good to avoid spaces in object names.
    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
    ladiross is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    3
    Quote Originally Posted by June7 View Post
    Your DLookup has bad quote marks as shown in red. Remove them.

    GRAMMI_CAL: DLookUp("[GRAMMATURA]";"GRAMMATURA";"[COD_PRODOTTO]= '" & [FORMS]![SCHEDA GIORNALIERA]![PRODOTTO] & "'" And "[COMMESSA]= '" & [FORMS]![SCHEDA GIORNALIERA]![COMMESSA] & "'")

    Try to avoid field and table names that are same. Common convention is to use plurals for table names.

    Title case is easier to read than all upper case. Also good to avoid spaces in object names.
    If [COMMESSA] is a calculated field, [COMMESSA_CAL] and not in a Maschera, what is the sintax?

    GRAMMI_CAL: DLookUp("[GRAMMATURA]";"GRAMMATURA";"[COD_PRODOTTO]= '" & [FORMS]![SCHEDA GIORNALIERA]![PRODOTTO] & "' And [COMMESSA]=[COMMESSA_CAL] & "'")

    which error in sintax?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Don't understand. What is a Maschera?

    Why would the criteria test one field against another field?

    Are Comessa and Commessa_Cal number types?

    Maybe:

    GRAMMI_CAL: DLookUp("[GRAMMATURA]";"GRAMMATURA";"[COD_PRODOTTO]= '" & [FORMS]![SCHEDA GIORNALIERA]![PRODOTTO] & "' And [COMMESSA]=" & [COMMESSA_CAL])

    or

    GRAMMI_CAL: DLookUp("[GRAMMATURA]";"GRAMMATURA";"[COD_PRODOTTO]= '" & [FORMS]![SCHEDA GIORNALIERA]![PRODOTTO] & "' And [COMMESSA]=[COMMESSA_CAL]")
    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.

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

Similar Threads

  1. dlookup problem
    By sdel_nevo in forum Programming
    Replies: 7
    Last Post: 08-19-2014, 08:20 AM
  2. Dlookup Problem
    By sdel_nevo in forum Programming
    Replies: 7
    Last Post: 05-22-2013, 03:05 PM
  3. Dlookup problem
    By Terava in forum Access
    Replies: 5
    Last Post: 04-29-2013, 11:05 PM
  4. DLookUP problem
    By Symlink in forum Access
    Replies: 7
    Last Post: 03-28-2013, 11:03 AM
  5. DLookup Problem
    By alsoto in forum Queries
    Replies: 5
    Last Post: 02-23-2012, 12:22 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