Results 1 to 4 of 4
  1. #1
    smaier is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jul 2020
    Posts
    43

    adding text to a dlookup return value

    Hello, all!



    What I'm trying to do is add some text to the return value of a dlookup depending on if the adjacent textbox has a value or not. This is through the Control Source of the textbox's properties.

    As an example:
    If Text1's value = 0.255 (this is a return of its current dlookup without trying to add anything)
    and Text2's value = 0.005
    Leave Text1's value as 0.255

    If Text1's value = 0.255
    and Text2 is empty
    Make Text1's rendered value will read (0.255)

    I tried something like:

    =IIf([Forms]![FormInQuestion]![Text2]=Null, "(" & (DLookUp("[TableField]","PartList","PN_ID = " & [Forms]![FormInQuestion]![TextBoxWithValueToMatch])) & ")", DLookUp("[TableField]","PartList","PN_ID = " & [Forms]![FormInQuestion]![TextBoxWithValueToMatch]))

    The part in bold is was my attempt at achieving this but it's not working as intended. I'm just getting/seeing the 0.255. Does this seem like it should work and my problem is elsewhere or is my syntax wrong?

    I do appreciate the help!

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    nothing = null, not even null

    try

    =iif(isnull(([Forms]![FormInQuestion]![Text2]),......

    also don't think you need all those brackets for the true part of the iif function

    DLookUp("[TableField]","PartList","PN_ID = " & [Forms]![FormInQuestion]![TextBoxWithValueToMatch])

  3. #3
    smaier is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jul 2020
    Posts
    43
    Quote Originally Posted by Ajax View Post
    nothing = null, not even null

    try

    =iif(isnull(([Forms]![FormInQuestion]![Text2]),......
    That was exactly it. Thank you so much.

    You were also right in there were unnecessary parenthesis in the true part if the iif. I'd been poking it with a stick for too long and was trying whatever I could think of :P

    Cheers, friend!



    Edit: Couldn't find a way to change the thread title to "Solved".

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    Couldn't find a way to change the thread title to "Solved".
    in the green bar at the top of the thread, click on 'thread tools'. The option is in the dropdown

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

Similar Threads

  1. How to make DLookup return formatted text
    By Nanuaraq in forum Queries
    Replies: 3
    Last Post: 07-26-2019, 02:55 PM
  2. Replies: 4
    Last Post: 06-26-2017, 12:19 PM
  3. DLookup return value
    By faythe1215 in forum Programming
    Replies: 3
    Last Post: 03-15-2015, 06:18 PM
  4. Return DLookup result as date?
    By kman42 in forum Access
    Replies: 8
    Last Post: 04-22-2011, 11:35 AM
  5. Dlookup to match two criteria and return value
    By randolphoralph in forum Programming
    Replies: 20
    Last Post: 05-20-2010, 12:27 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