Results 1 to 5 of 5
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919

    DLookup as ControlSource for a text box?

    I have a table where I want to store recordID's and have the ID's used to find values in another table when the ID's are greater than zero and use those values to populate a text-box. I think I essentially want an un-bound text-box with a value lookup when the ID is non-zero. If that's the correct thinking, what would an expression look like for the unbound textbox? Something like: If ID>0 then dlookup value1 in mytable where recID = ID ????



    I tried to accomplish the task within a query, but couldn't find success there. Also with the DB relationship but doesn't handle the zero ID properly.

    Thanks,
    Bill

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Why would ID be 0? What field do you want to return value from?

    =IIf(ID>0, DLookup("field","table","ID=" & [ID]),Null)
    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.

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    ID's are being assigned. If an assignment has been made, then the textbox would be populated with text values taken from the table from which the ID's are found. If an ID is zero, then the textbox should be a zero-length string.

    I'll try your expression and post back.
    Bill

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    For zero-length string:
    =IIf(ID>0, DLookup("field","table","ID=" & [ID]),"")
    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
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Thanks, issue solved.
    Bill

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

Similar Threads

  1. Textbox ControlSource Question
    By RonL in forum Forms
    Replies: 4
    Last Post: 02-16-2013, 12:18 AM
  2. DLookup with Text
    By Kirsti in forum Programming
    Replies: 8
    Last Post: 06-26-2012, 07:56 PM
  3. Dynamic Text Box ControlSource from multiple tables
    By cjtezak in forum Programming
    Replies: 2
    Last Post: 06-20-2012, 10:07 AM
  4. Replies: 2
    Last Post: 10-27-2011, 10:28 AM
  5. Subform ControlSource Popup issue
    By GraemeG in forum Forms
    Replies: 10
    Last Post: 04-07-2011, 11:52 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