Results 1 to 8 of 8
  1. #1
    Niki is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Apr 2011
    Posts
    32

    Easy DLookup Issue

    Why is this not working?



    Brand = DLookup ("[Brand]", "[IngredientsTable], "[FoodName]= " & [FoodName])

    Does it not say that the Brand field on my form should equal the Brand field from the IngredientsTable when FoodName from the IngredientsTable equals the FoodName from the drop down box on my form?

    I'm missing something obvious....

    Thank you~

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Well, it would help if you clarified what "not working" means, but if the FoodName is a text field the syntax is different:

    DLookup Usage Samples
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Niki is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Apr 2011
    Posts
    32
    It just keeps giving me the debugger. I tried all 3 methods referring to a form control and I still can't get it to work!

    I've attached my DB - if you look on the Form Recipe - not recipes - you'll see I'm trying to get different ingredients listed depending on the recipe. I'd like to be able to select an ingredient from each combo box and populate the text fields to the right depending on the combo box selection. I have used a recordset clone for combo box one to too great effect, and it has populated all my text boxes because, presumably, the control source. I'm trying a DLookup with combo box 2, to see if that would work better for what I'm trying to do.

    Thanks for any help!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    You're comparing an id value against a text value. This works:

    Text57 = DLookup("Brand", "IngredientTable", "id=" & Forms!Recipe!myselector1)

    as does

    Text57 = DLookup("Brand", "IngredientTable", "FoodName='" & Forms!Recipe!myselector1.Column(1) & "'")

    But I'd avoid the DLookup entirely and do this:

    http://www.baldyweb.com/Autofill.htm

    That way the combo has done all the looking up for you. It's more efficient.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Niki is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Apr 2011
    Posts
    32
    Dude. Seriously. I've been working on that for 2 weeks.

    Sweet! Thank you so much!!!

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Niki is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Apr 2011
    Posts
    32

    Last one...

    Glad to hear it because I have another question - lol.

    I've created a text box and asked it to =[Cost Srvg]+[Text197] and it concatenates the feilds instead of summing them.

    I've tried =Sum([Cost Srvg]+[Text197]) to no avail - I get #Error.

    Thanks in advance!

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    My copy doesn't appear to have a Text197, so I'm not sure what it is. From the sound of it, it contains text data, not numeric, which is why Access will concatenate it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 0
    Last Post: 03-29-2011, 09:37 AM
  2. Easy Question Need Help With
    By jdusaf in forum Access
    Replies: 1
    Last Post: 03-23-2011, 11:33 AM
  3. Tough form issue that uses DLookup's
    By Solola in forum Forms
    Replies: 3
    Last Post: 03-15-2011, 01:25 PM
  4. I know this has to be easy...
    By MelindaP in forum Access
    Replies: 7
    Last Post: 08-20-2010, 02:15 PM
  5. Replies: 2
    Last Post: 04-16-2010, 09:24 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