Results 1 to 7 of 7
  1. #1
    mdavid is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    160

    use combo box selection as source for text box

    Hi, I have a combo box with the following query:



    SELECT MempSpecies.SpeciesName
    FROM MempSpecies
    WHERE (((MempSpecies.SpeciesID)<600));

    the MempSpecies table also contains the field Family

    Family
    and SpeciesID appear as text boxes. What do I need to write in Control Source for these fields to receive the values from the selected record in the combo box?
    Thanks for any help
    David

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,971
    Include SpeciesID and Family as columns in the combobox.

    SELECT SpeciesID, SpeciesName, Family FROM MempSpecies WHERE SpeciesID<600;

    Then reference the combobox columns by index. Index begins with 0 so if data is in column 2 the index is 1. Expression in textbox ControlSource property:

    =Comboboxname.Column(1)

    Really should save SpeciesID not SpeciesName.
    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
    mdavid is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    160
    Thanks for the quick reply, I only want to see SpeciesID and SpeciesName in the combo box. I need family to appear in a separate text box, so with the above query how many columns does the combo box have? Is it 3 with Family column width 0?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,971
    3 columns and any column you want to hide should be width 0.

    Only the fields not set to 0 will display in the list. The first column not set to 0 will show in the box. The BoundColumn will be save to field.
    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
    mdavid is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    160
    Hi, the Combo box name is cmdMempSpecies


    the Family control source is: =[cmdMempSpecies].[Column](2)

    in the Family text box I receive: #Name?


    ​What am I doing wrong?

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,971
    cmd is usually a prefix for a command button, not a data control.

    Access does not find combobox named cmdMempSpecies.
    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.

  7. #7
    mdavid is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    160
    Thanks very much, seems I'm a bit dyslexic, my combo box is called cmbMempSpecies.

    Now all's working perfectly.

    Thanks again

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

Similar Threads

  1. Replies: 1
    Last Post: 08-27-2015, 01:11 PM
  2. Populating Text box after selection from Combo Box
    By coach32 in forum Programming
    Replies: 3
    Last Post: 03-19-2014, 10:15 PM
  3. Replies: 3
    Last Post: 12-11-2012, 09:12 AM
  4. Replies: 3
    Last Post: 03-15-2012, 02:27 PM
  5. Replies: 9
    Last Post: 05-30-2011, 01:52 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