Results 1 to 6 of 6
  1. #1
    Phil H is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Dec 2019
    Location
    Phoenix, AZ
    Posts
    19

    Accessing ComboBox values on a form with VBA code behind the form


    I have a Combo Box on a "Menu" form. The source is a three field table that defines facility locations. The Combo Box is Unbound. The "User" is asked to click on the Combo and select one of the facilities. Field 1of the table is the the ID (Autonumber), Field 2 is the name of the facility, and Field 3 is an ID code. I want to access fields 2 and 3 from procedures behind the form. When I use code like X = Me!ComboName, I get the ID field (i.e., a number) of the selected entry. I don't know how to get at the other two fields. I have tried X = Me!ComboName(n) where n in this case is 2 or 3 but that doesn't work. I've also tried X = Me!ComboName("facility") and that doesn't work either. I've read all I have on Combo boxes, but nothing addresses this specific topic (at least not that I've found). Maybe this isn't even possible?
    I'll appreciate any help...Phil H

  2. #2
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    Most Access collections are zero-based so you need to use Me.ComboName.Column(1) for the facility name and Me.ComboName.Column(2) for the third field Id code. And make sure the columns (number of) property of the combo is set to 3.
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    orange's Avatar
    orange is online now Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

  4. #4
    Phil H is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Dec 2019
    Location
    Phoenix, AZ
    Posts
    19
    Quote Originally Posted by Gicu View Post
    Most Access collections are zero-based so you need to use Me.ComboName.Column(1) for the facility name and Me.ComboName.Column(2) for the third field Id code. And make sure the columns (number of) property of the combo is set to 3.
    Cheers,
    Vlad:
    Thank you...that's exactly what I needed. I have never run across the use of "column" in that context before, although the use of "column" in several of the ComboBox properties maybe should have suggested something to me. Anyway, it will make my ACCESS life a little easier now.
    Thanks also to Orange for the references to the ComboBox articles. I wish I'd had those before.
    I would mark this as "Solved" except that when I click on Thread Tools, all I get is "Show Printable Version".
    Thanks again, Phil H

  5. #5
    Phil H is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Dec 2019
    Location
    Phoenix, AZ
    Posts
    19
    OK, after I submitted the above, I went back to the top and clicked on Thread Tools again. This time I got the "solved" option and selected it.

  6. #6
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Replies: 2
    Last Post: 04-09-2016, 01:23 PM
  2. Base Combobox values on another form control
    By jhrBanker in forum Forms
    Replies: 4
    Last Post: 03-20-2015, 03:13 PM
  3. Form combobox won't bring up values
    By sevanty7 in forum Access
    Replies: 7
    Last Post: 05-17-2013, 11:45 AM
  4. Generate form based on combobox values
    By OatmealJones in forum Forms
    Replies: 3
    Last Post: 02-13-2013, 04:08 PM
  5. Adding values to a combobox with code
    By jle0003 in forum Access
    Replies: 4
    Last Post: 05-23-2012, 02:15 PM

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