Results 1 to 15 of 15
  1. #1
    ramirezx@ddmfg.com is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    40

    On Double Click value will not copy in ComboBox with two columns

    Hi,

    I have a text box that when I double click, I want it to copy value from that text box to the combo box


    This works with no problem:
    Forms![frm_05a_COMPONENTS].[Text42] = [COMPONENT_PART_NUM]

    This combo box will not work, combo box stays blank:
    Forms![frm_05a_COMPONENTS].[Combo44] = [COMPONENT_PART_NUM]

    The only difference is Combo44 has 2 columns 1 is not visible, Column width is (0";1"), and Bound Column is 1. I tried this and with no luck

    Forms![frm_05a_COMPONENTS].[Combo44]
    .Column(0)= [COMPONENT_PART_NUM]
    Forms![frm_05a_COMPONENTS].[Combo44].Column(1)= [COMPONENT_PART_NUM]



    Still no luck, basically I want to copy value from one text box to a combo box, but having multiple columns is creating the problem.

    I hope someone can help?

    Thanks,
    Xavier

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Can you give us an example of the data in each of the combo columns and the data in the textbox
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    ramirezx@ddmfg.com is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    40
    Hi!

    The first column have a value ASSEMBLYN/A2547117
    The second column has a value - 2547117

    Thanks,
    Xavier

  4. #4
    ramirezx@ddmfg.com is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    40
    Also when I change the combo box to 1 column, it work. So I know the problem is coming from having multiple columns.

    Thanks,
    Xavier

  5. #5
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Is 2547117 the value entered into the text box
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  6. #6
    ramirezx@ddmfg.com is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    40
    No, the text box was created just to see if the code was wrong. It works with the text box, but not with a combo box that has multiple columns

  7. #7
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    On reflection, why not just type the data into the combo rather than the textbox?
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  8. #8
    ramirezx@ddmfg.com is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    40
    I just want to copy and past a value from a text box and paste it in the combo box using vba

  9. #9
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by ramirezx@ddmfg.com View Post
    No, the text box was created just to see if the code was wrong. It works with the text box, but not with a combo box that has multiple columns
    Then I don't understand what you are trying to do.
    This combo box will not work, combo box stays blank:
    Forms![frm_05a_COMPONENTS].[Combo44] = [COMPONENT_PART_NUM]
    I assumed that [COMPONENT_PART_NUM] is a textbox which, when double clicked, would select that value from the values in the combo.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  10. #10
    ramirezx@ddmfg.com is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    40
    the combo box is a search filed, I have records that linked to different part #'s, when I see a list of other part #'s i want to click and have it replace it with the other part # and do the search without having to type the part # in multiple areas

  11. #11
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by ramirezx@ddmfg.com View Post
    I just want to copy and past a value from a text box and paste it in the combo box using vba
    Then I'll repeat my earlier question: why not just type the data into the combo rather than the textbox?
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  12. #12
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by ramirezx@ddmfg.com View Post
    the combo box is a search filed, I have records that linked to different part #'s, when I see a list of other part #'s i want to click and have it replace it with the other part # and do the search without having to type the part # in multiple areas
    Your code:
    Forms![frm_05a_COMPONENTS].[Combo44] = [COMPONENT_PART_NUM]
    will work if the data in [COMPONENT_PART_NUMt] is the same as the data in second combo column
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  13. #13
    ramirezx@ddmfg.com is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    40
    Because they would have to type on multiple forms, I want to put code to replace the value in 8 forms, 8 combo boxes.

    I don't want the user to have to type the part # in all ten fields/combo boxes

    Thanks,
    Xavier

  14. #14
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,815
    IF the field data types in textbox and combo bound column are the same it can work with multiple columns so that is not the problem. Let's say bound combo and textbox fields are numeric and you dblclick textbox when it has a value of 3. You will put whatever is in the first visible column that matches the PK field that the combo is bound to (e.g. combo is bound to employee table, PK of 3 matches 12345 employee number, employee number is 1st visible column, combo will now show value of 12345. If that's what you want, it can work. However, it is unlikely that you know the value of the PK field, especially if it is an autonumber. Even if you did, 3 is the value you want to set in the combo, not 12345 so IMO the idea is impractical because the only data that can be retrieved/inserted from/into a bound combo is in the bound field. It doesn't matter what you see that you've selected from the list if it's different.

    Populating fields in opened forms is doable so it may just be that you need to run code when you open subsequent forms (and the 1st one is still open) and get the values that way.
    Last edited by Micron; 04-01-2022 at 02:08 PM. Reason: clarification
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  15. #15
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,119
    The first column have a value ASSEMBLYN/A2547117
    The second column has a value - 2547117
    Would you please try something like this (assumes the value displayed in the second column is always at the end of the first column):
    Code:
    Forms![frm_05a_COMPONENTS].[Combo44] = DLookup("SourceFieldForFirstColumnOfCombo","SourceTableForCombo","[SourceFieldForFirstColumnOfCombo] Like '*" & [COMPONENT_PART_NUM] & "')
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Replies: 1
    Last Post: 11-15-2021, 04:33 AM
  2. Replies: 4
    Last Post: 06-17-2019, 05:17 PM
  3. Double Click Listbox
    By HelpDesk in forum Access
    Replies: 12
    Last Post: 06-29-2015, 10:38 AM
  4. double click to open
    By spleewars in forum Programming
    Replies: 7
    Last Post: 05-22-2012, 11:52 AM
  5. Replies: 8
    Last Post: 05-26-2011, 09:23 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
  •  
Other Forums: Microsoft Office Forums