Results 1 to 7 of 7
  1. #1
    epardo87 is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Dec 2016
    Posts
    101

    display in txtbox value from tableaccording to listbox

    Hello All,




    • In a form "frm20SelectArea" there is a listbox "lstArea" with two values (Area A & Area B)
    • There is also a textbox "txtSup" in the same form
    • Finally I have a table "tblArea" with three columns (AreaID, Area & Supervisor)



    • How can the textbox display the supervisor looked up in the table according to the area selected in the list box?


    i'd appreciate your help a lot!

    Click image for larger version. 

Name:	Untitled.jpg 
Views:	7 
Size:	24.9 KB 
ID:	27008

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    A DLookup() would be one way:

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

  3. #3
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Actually this would be simpler if the listbox can contain the fields:

    BaldyWeb - Autofill
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    epardo87 is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Dec 2016
    Posts
    101
    Quote Originally Posted by pbaldy View Post
    A DLookup() would be one way:

    DLookup Usage Samples
    Thank you!

    I tried the one for strings but it gives me #Name? what do you see wrong?

    =DLookUp([Supervisor],[tbl-1-0-Areas],"[Area]='" & [Forms]![frm20SelectArea]![lstArea] & "'")

  5. #5
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    The first two arguments must also be enclosed in quotes.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    epardo87 is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Dec 2016
    Posts
    101
    Quote Originally Posted by pbaldy View Post
    The first two arguments must also be enclosed in quotes.
    Excellent!! that worked perfectly!

    Thanks so much for your help pbaldy!

  7. #7
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help!
    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. Display row number of listbox selected
    By tozey in forum Forms
    Replies: 2
    Last Post: 07-20-2016, 08:43 AM
  2. Cannot get Listbox to display records
    By edmscan in forum Queries
    Replies: 5
    Last Post: 07-22-2014, 12:54 PM
  3. Replies: 6
    Last Post: 08-01-2013, 12:31 PM
  4. Display RESULTS of Query into LISTBOX?
    By taimysho0 in forum Programming
    Replies: 6
    Last Post: 11-22-2011, 10:05 PM
  5. Replies: 2
    Last Post: 08-12-2011, 01:01 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