populate form text fields depending on combo box selection

S

Steve Halley

Hi Everyone

I have a form which uses a number of combo boxes to select criteria for a
query. The basic form and query functionality is fine, but I would like to
display additional information on the form when a combo box selection is
made. For example ... when a supplier has been selected from the combo box,
the supplier number is displayed in the combo box field as expected. I would
also like to display the corresponding supplier name in a nearby text box.
(and commodity description next to commodity code, product description next
to product code etc)
I have tried a number of ways of doing this, but my text boxes remain
stubbornly blank! Can anyone point me in the right direction in principle,
so I can focus my efforts without barking up the wrong tree?

Thankyou, thankyou, thankyou !
 
M

Marshall Barton

Steve said:
I have a form which uses a number of combo boxes to select criteria for a
query. The basic form and query functionality is fine, but I would like to
display additional information on the form when a combo box selection is
made. For example ... when a supplier has been selected from the combo box,
the supplier number is displayed in the combo box field as expected. I would
also like to display the corresponding supplier name in a nearby text box.
(and commodity description next to commodity code, product description next
to product code etc)


If the combo box's RowSource table/query includes the
desired information, you can just set the related text box's
control source expression to this kind of expression:
=combobox.Column(1)
to display the second field in the row source.

If the data is not in the row source table/query, then you
will have to retrieve the field from it's table. You can
use a text box expression for this, but for efficiency, you
should probably use code on the combo box's AfterUpdate
event procedure (and, probably, in the form's Current
event):

Me.thetextbox = DLookup("[supplier name]", _
"suppliers table", "[supplier number]=" & Me.combobox
 

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