Results 1 to 5 of 5
  1. #1
    angybab is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Oct 2020
    Posts
    35

    Display the 2. value selected from a combo box in a text field

    Hi again,
    My combobox has two cloumns. First column has a code and the second a description.
    The first column is bounded.
    I added a text field so that when I make a selection, the code is displayed in the combobox and the corresponding text in the text field.


    I use a vba code that looks like this:

    Private Sub cboSomething_AfterUpdate()
    Me!txtSomething= Me!cboSomething.Column(1)
    End Sub

    since this didn't work. I changed it to :

    Private Sub cboSomething_AfterUpdate()
    Me.txtSomething= Me.cboSomething.Column(1)
    End Sub

    but it's still not working. Can anyone help?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,896
    Is textbox UNBOUND? Code won't work nice for continuous or datasheet form because setting an unbound textbox value will show the same for every instance of textbox.

    Don't really need VBA. Expression in textbox ControlSource can display combobox text: =[cboSomething].[Column](1)

    Why do you want code to show in combobox? If this is an autonumber value then it should not have meaning to users and no need to display.
    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
    angybab is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Oct 2020
    Posts
    35
    Hi, thanks for your quick response. Yes the textbox is unbound
    I will try that to see if it will work

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    ignore - you have set the combo to have two columns

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,784
    Quote Originally Posted by Ajax View Post
    ignore - you have set the combo to have two columns
    But the first column width should be zero, which was only mentioned in the abstract. I don't see a need for a text box to display a value that's being shown in a combo list when you can just show it in the combo.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 3
    Last Post: 10-18-2017, 11:35 AM
  2. Replies: 1
    Last Post: 02-06-2016, 05:33 AM
  3. Replies: 2
    Last Post: 08-05-2015, 04:06 PM
  4. Replies: 2
    Last Post: 05-13-2015, 03:20 PM
  5. Replies: 1
    Last Post: 02-04-2015, 03:12 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