Retrieve the selection (click) from a listbox and display it in a Textbox.

Solved
#jquem# Posted messages 76 Status Member -  
#jquem# Posted messages 76 Status Member -
Hello,
I'm trying to create a form where I've implemented product searching by keyword.
When the list of products appears, I would like that by clicking on the chosen product, it shows up in a TextBox and the content of the ListBox disappears.

Can someone help me, please?
(for your information, I'm "doodling," but I've never had any VBA courses.

Thank you in advance.

5 answers

  1. m@rina Posted messages 27549 Registration date   Status Moderator Last intervention   11 562
     
    Hello,

    When you talk about "form", you need to be more specific:

    - Userform?
    - Form controls in a sheet?
    - ActiveX controls in a sheet?

    m@rina

    --
    From now on, if a user tells me "it doesn't work" without any more information..., I'm giving up!
    0
  2. #jquem# Posted messages 76 Status Member
     
    Hello and thank you for your reply.

    It's a userform.

    me@n
    0
  3. m@rina Posted messages 27549 Registration date   Status Moderator Last intervention   11 562
     
    Hello,

    Normally you should have a macro that initializes your listbox.

    Then you create a macro that will activate on a click in your listbox:

    Private Sub ListBox1_Click()
    Dim choice
    choice = Me.ListBox1.Value
    Me.TextBox1.Value = choice
    Me.ListBox1.Clear
    End Sub


    m@rina

    0
  4. #jquem# Posted messages 76 Status Member
     
    Is it possible to send you my file via monpartage.fr?
    This would allow you to identify my gaps, or even mistakes...

    Thank you
    je@n
    0
  5. #jquem# Posted messages 76 Status Member
     
    Thank you very much, Marina! That works!

    je@n
    0