Edit contacts; fill textbox out of listbox

Bandito1

Board Regular
Joined
Oct 18, 2018
Messages
82
Hi all,

I'm making a contactbook for phone contacts.

On userform frmTelephoneSearch i have a listbox named lstSearchResults. It displays all my contacts.

Now i would like to make a new userform to edit contacts that are in lstSearchResults.
I would like to select a name in the lstSearchResults, press a button and open a new userform and there there are textboxes that are filled with the data i clicked in lstSearchResults.

I made this test;

Code:
Private Sub lstSearchResults_Click()TextBox1.value = lstSearchResults.Text
End Sub
It works, the Full name is displayed in textbox1. But i would like that textbox on another userform.
Also there is more date; Full name, Department, Gender, phone and email. How do i specify each column to a textbox?

Hope someone can help.
Thanks in advance.
 

Bandito1

Board Regular
Joined
Oct 18, 2018
Messages
82
Found the answer on this;

It works, the Full name is displayed in textbox1. But i would like that textbox on another userform.
Also there is more date; Full name, Department, Gender, phone and email. How do i specify each column to a textbox?


Code:
[/COLOR]Private Sub UserForm_Initialize()
Me.txtSurname.value = frmTelephoneSearch.lstSearchResults.value
Me.txtDepartment.value = frmTelephoneSearch.lstSearchResults.Column(1)
End Sub
[COLOR=#333333]
 

Forum statistics

Threads
1,081,556
Messages
5,359,547
Members
400,533
Latest member
fpenning

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top