Results 1 to 5 of 5
  1. #1
    bahalzamon is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2015
    Location
    Phoenix, AZ
    Posts
    23

    Listbox unbound records

    Hello,

    I have an unbound listbox and some unbound text boxes.
    I am attempting to create code that will fill in the text boxes depending on which record I select within the list box.
    The listbox does not have multi select on, only single select is possible.
    I found listBox.Value which gives me the primary key which is nice, its something.

    I have attempted several ways of things I have found online with no luck on how to get the remaining information into the other text boxes.
    I have seen a for loop to find the one that is selected then using the listboxControl.Column(intColumn,intRow) but I obviously don't understand how to implement it.
    The other option is to use a query but I am apparently doing that incorrect as well.
    The query:
    Code:
    "SELECT [Student].[firstName] WHERE [Student].[SSID] = studentList.Value;"
    I think this is the correct query but I cant seem to implement it either.



    If you need/want any of how the code looks now please let me know. I know you don't want people saying "tell me how to do it." So if you have any resources I am good reading up further on it, I just cant find a place that I can get the required info. =)

    Any help would be greatly appreciated.
    -Bahalzamon

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    you cant set a text box to many records from a multi select list. text boxes only hold 1 value.

    if you need multiple values selected, dont use a multiselect list (takes lots of programming) instead, use a single -click action
    to run an append query to put that item in a 'picked list' table.
    This table can be joined with your main data to pull ONLY these items. 1 command, no programming.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Are the textboxes bound to fields? If so, why?

    Expression in textbox ControlSource can reference columns by index. Index begins with 0. So column 2 would be index 1.

    =[studentList].[Column](1)
    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.

  4. #4
    bahalzamon is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2015
    Location
    Phoenix, AZ
    Posts
    23
    @ranman256,

    I do NOT need multiple values selected, just 1, and I wanted the text box to populate with the singularly selected item within the list box.
    I am unfamiliar on what it is you are referring too, sorry, I am very new to Access, I am just unfamiliar with the syntax of Access.
    Either way June7 came through again and answered it below. =)

    -Bahalzamon

  5. #5
    bahalzamon is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2015
    Location
    Phoenix, AZ
    Posts
    23
    @June7,

    Wow do I ever feel dumb.
    No the text boxes are not bound and I was attempting to keep them from that, having them unbound allows for more freedom.
    I just needed them to fill in from the list box, I was not aware that that would work, I would have thought it would pull the entire column.
    But now looking at it I should have known due to the listBox.Value returns the key, so basically telling it to use the key and go over X number of spaces. =)

    Thanks again man, marking as Solved!
    -Bahalzamon

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

Similar Threads

  1. Replies: 11
    Last Post: 08-10-2015, 06:27 PM
  2. Replies: 5
    Last Post: 06-23-2014, 03:32 PM
  3. View Attachment in Unbound listbox
    By cuddles in forum Forms
    Replies: 6
    Last Post: 06-10-2014, 03:28 PM
  4. Replies: 2
    Last Post: 12-21-2012, 01:57 PM
  5. Populate unbound listbox with VBA
    By usmcgrunt in forum Forms
    Replies: 1
    Last Post: 09-23-2010, 09:11 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