Results 1 to 7 of 7
  1. #1
    laavista is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2010
    Posts
    42

    Question DLOOKUP in textbox on form

    I'm using Access 2010. I'm having trouble with dlookup. I've spent over 5 hours searching forums, etc., and can't figure out what I'm doing wrong.



    Table name: tblTier2
    Fields: Tier2ID, autonumber
    Tier2FieldType, text

    I have an unbound list box on a main menu form.
    The listbox control is numeric and called: lstItem

    I tried putting the following in the textbox:

    Neither of these worked:
    = DLookUp("[Tier2FieldType]","[tblTier2]","[Tier2ID]=" & [lstitem])
    =DLookUp("[Tier2FieldType]","[tblTier2]","[Tier2ID]=" & [lstitem].[column](0))

    I wanted to see if the lstItem was the problem, so I put ths following in the text box. :
    =[lstitem] (it returned the ID number selected from the list box, e.g., 809)

    Your help would be so appreciated.
    Thanks.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Is the textbox also on the main form?

    Why do you need to show this value in textbox? Why not just have it as a column in the listbox?

    Why is this an unbound listbox?
    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
    laavista is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2010
    Posts
    42
    I need to cascade information. I have two list boxes--both on the 'main form'. The user selects data from tier1 in listbox1. Listbox2 displays the data for the tier1 selection. I now need to display 9 fields for the tier2 selection and some of the fields are lengthy.

    Listbox 1 for tier1 is associated with a table.
    Listbox 2 for tier2 is unbound
    This works.

    Now I need to display the 9 fields based on the user's selection from listbox 2. I thought a dlookup for each of the 9 fields might work best. I've tried adding in a form, but could not get that to work either.

    Any suggestions?
    Thanks for looking at this.

  4. #4
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Where are you wanting to display these 9 fields at? You don't need a dlookup, just make the field equal the value for each row.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Include the fields as columns in combobox. Then expression in textbox references the listbox column index.

    =[lstitem].[Column](3)

    What purpose does the second unbound combobox serve?
    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.

  6. #6
    laavista is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2010
    Posts
    42
    I want to display the 9 fields anywhere on the form, but the form is not based on the table where the 9 fields reside.

  7. #7
    laavista is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2010
    Posts
    42
    Please ignore this question. I found I had an error in my database structure.
    Thank you for your help.

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

Similar Threads

  1. Textbox using dlookup for Query
    By CTdbdev in forum Forms
    Replies: 2
    Last Post: 08-04-2014, 07:45 PM
  2. Replies: 3
    Last Post: 07-11-2014, 08:13 AM
  3. Replies: 6
    Last Post: 06-09-2014, 12:13 AM
  4. Dlookup with criteria of textbox
    By thescottsman92 in forum Access
    Replies: 3
    Last Post: 08-30-2013, 03:32 AM
  5. Replies: 4
    Last Post: 05-31-2013, 07:00 PM

Tags for this Thread

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