Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Apr 2010
    Location
    Sofia
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    On my form i want to build a dlookup control looking for the code in the query "QryProductSales" with the crieria called code.I have the control code in the form and i want to look up for the data with the corresponding code in my query.I have built partly the control but i could not define the criteria, they should be as follows : where code in the form is equal to the code in the query. Can you help me ?
    My following control has no criteria and cannot work:
    ="Sales: " & "" & DLookUp("[Bought]";"QryProductSales") where ........?

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    Try
    ="Sales: " & "" & DLookUp("[Bought]";"QryProductSales", "[code] = " & chr(34) & me.[code] & chr(34))

    This assumes that Code is the field, and is a text field.
    Regards
    John



  3. #3
    Lounger
    Join Date
    Apr 2010
    Location
    Sofia
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you very much for your reply.I tried to use it and i got the following error:
    "The expression you entered contains invalid syntax. You omitted an operand or operator,you entered an invalid character or comma,or you entered text without surrounding it in quotation marks."
    Is it possible that since i am from East Europe, the syntax may be different, i mean ; or ' or something like that?

  4. #4
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts
    You could try these two

    If the code field is text then try

    ="Sales: " & "" & DLookUp("[Bought]";"QryProductSales", "[code] = '" [code] "'")

    If the Code field is Numeric then

    ="Sales: " & "" & DLookUp("[Bought]";"QryProductSales", "[code] = " [code])

    Another possibility would be

    ="Sales: " & "" & DLookUp("[Bought]";"QryProductSales", "[code] = Forms![NameOfYourForm]![Code])
    Andrew

  5. #5
    Lounger
    Join Date
    Apr 2010
    Location
    Sofia
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you very much with the help of your suggestion i have solved my problem!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •