copy values from ListBox to a TextBox

G

Guest

hi,
i'm trying to copy the values from one listbox to the textbox, how can i do
this?
the listbox just show one value. i have to use listbox because it is the
value from an SQL statement.
Any sugestion
 
G

Guest

There is no reason to create a list box for only one value, you can retrieve
the value using dlookup, or any other method
If you tell us what you are trying to do, mybe we can help you and recommand
a different method

To copy from a list box, you need to select the record and then
Me.TextBoxName = Me.ListBoxName
 
G

Guest

hi again,
i have a list box, that have a list with the names, and when i select one
name it appear the code (Listbox), i use a listbox because i can't retrieve
the value with the select statement, from the listbox names. if you know
other way to get the value without using listbox, i will aprecciate.
thanks

"Ofer" escreveu:
 
G

Guest

If you have a list of names, and you select just one of them, to move the
value selected in the list box to the text box use the After update event of
the ListBox and write the code

Me.TextBoxName = Me.ListBoxName

Now, if the list box contain more then one field, and you want to transfer
the second field, then use this
Me.TextBoxName = Me.ListBoxName.column(1)

The column number count start with 0
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck
 
G

Guest

hi, it didn't work, i will explain better
i have a table with this fields----> Name, code, adress
now i have a listbox with all the names in the table and when i select one
of them i want in the code, adress listbox appear the values corresponding to
the name. i use the listbox, because, i am using an SQL statement to check
the values of the code and the adress. if try with the texbox it don't appear
nothing, so if you know how to get the value from the name selected to a
testbox.
thanks

"Ofer" escreveu:
 
G

Guest

Let start from the beginning
1. Create a list box that include all the fields in the table
Select [Name], code, adress From TableName
You don't need to display all the fields in the list box, you can display
only the name

2. On the after update event of the lsit box, write

Me.TextBoxName = Me.ListBoxname.Column(2)

--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck
 
G

Guest

hi, it works, but idid in other.
now i have a textbox that will receive the code, but to receive i have to
click in the listbox of the code, how can i do to the textbox receive the
value automaticly without press the lisbox. thanks



"Ofer" escreveu:
Let start from the beginning
1. Create a list box that include all the fields in the table
Select [Name], code, adress From TableName
You don't need to display all the fields in the list box, you can display
only the name

2. On the after update event of the lsit box, write

Me.TextBoxName = Me.ListBoxname.Column(2)

--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



Bruno Coelho said:
hi, it didn't work, i will explain better
i have a table with this fields----> Name, code, adress
now i have a listbox with all the names in the table and when i select one
of them i want in the code, adress listbox appear the values corresponding to
the name. i use the listbox, because, i am using an SQL statement to check
the values of the code and the adress. if try with the texbox it don't appear
nothing, so if you know how to get the value from the name selected to a
testbox.
thanks

"Ofer" escreveu:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top