Filling in text boxes based on a listbox and table??

P

PT

So I have this listbox in an option group, lstInfo This listbox is
based on a query from my customers table, in it I am only displaying
the Last Names when a user clicks on the dropdown.

I have textboxes on the form. TXTADDRESS, TXTPHONE, TXTSTATE

When someone selects a last name from the lisbox dropdown I want those
UNBOUND Textboxes to also display that information for the current
person selected, so if I selected Smith it would fill TXTADDRESS with
Smiths address that it takes from the customers table.

Remember these text boxes are unbound.

How would I do this?

thanks
 
G

Guest

How do you put a list box in an option group?
Only the last name? You must work at a very small company if you expect to
have only one Smith.

There are a couple of ways to do what you want to do, but I think we need to
understand what the objective is before we come up with a solution.
 
P

PT

Sorry its not a company just something I want to do and try.

Basically I have a small table with Names, address, phone etc. in it,
say 20 names, something I made up myself to see if this would work. I
then built this listbox and it displayes last names from this table.

I then want to take the last name that is in the listbox, match it up
to the table and fill in my unbound textboxes of ADDRESS, STATE, etc.
All the address, state, info is in the table.
 
M

Marshall Barton

PT said:
So I have this listbox in an option group, lstInfo This listbox is
based on a query from my customers table, in it I am only displaying
the Last Names when a user clicks on the dropdown.

I have textboxes on the form. TXTADDRESS, TXTPHONE, TXTSTATE

When someone selects a last name from the lisbox dropdown I want those
UNBOUND Textboxes to also display that information for the current
person selected, so if I selected Smith it would fill TXTADDRESS with
Smiths address that it takes from the customers table.


The easest way to deal with this kind of thing is to include
the desired fields in the list box's row source query. Then
the text boxes can display the fields just by using an
expression like:
=listbox.Column(2)
to display the third field in the query. Be sure to adjust
the list box's ColumnCount property.
 

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