Results 1 to 6 of 6

Combo Box: How do I change what column to display in the combo control, after a selection is made

  1. #1
    NKB is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    30

    Combo Box: How do I change what column to display in the combo control, after a selection is made

    In a combobox, the leftmost column is the bound column, in my case, and it is the ID field (Say the customer ID), and it is also hidden. I found out that, by default, the displayed text in the combo box space, after a selection is made, is column 1, the column to the right of the bound column. How do I change that? :et's say I want to display column 3 or 4 after a user makes a selection?



    I meant in VBA I want a code like AfterUpdate:

    Me.cboCustomers = me.cboCusterms.column(3)

    but this is wrong!

    How do I do it. I researched and could not find a solution.

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,047
    Just refer to mystring = me.cbocustomers.column(3)

    Remember that your cbobox properties must have column count 3 or more for this to work

  3. #3
    NKB is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    30
    andy49,

    I meant in the same cbo control, not in another control. mystring you referred to here is another control, maybe a text box field. I want the displayed info, of my choice, to be in the same cbo control. Instead of displaying column x I want to display column Y. I hope this clarifies my point further.

  4. #4
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,047
    Oh do you mean you want to make column 1 and 2 invisible but see column 3 and or 4??

  5. #5
    NKB is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    30
    Here is more clarification, let's say I have the following data in Custerms table.

    ID, FirstName, Profession
    1, John, Engineer
    2, Dave, Artist
    3, Bill, Pilot

    and so on...

    In the combo box, all columns are displayed, except that column 0 which is the ID is hidden (its width is set to 0). If I make a selection, say (John Engineer), then bound column would be assigned to the control source (CustomerID=2), and the displayed text would be "John". I want to change that to display "Engineer" instead.

  6. #6
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,047
    In properties of combobox look on first tab for column widths. Should be numbers first of which is a zero to hide the first field. Change whichever column you want to see.

    For example

    0;0;2;3will allow you to see column 3 and column 4 only

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

Similar Threads

  1. Combo Box will not allow selection to be made
    By Ceichhorn in forum Forms
    Replies: 17
    Last Post: 03-01-2017, 11:11 AM
  2. Replies: 5
    Last Post: 08-05-2014, 09:13 AM
  3. Replies: 10
    Last Post: 01-31-2014, 09:47 AM
  4. Replies: 3
    Last Post: 07-03-2013, 10:38 AM
  5. Replies: 3
    Last Post: 12-11-2012, 09:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Tech Forums: Microsoft Office Forums