combo boxes and text boxes

S

StuJol

I've been trying to do this ever since i've had access which isnt that long
but i just cant seem to get it right, can someone please help me out.

i have a form "Invoices" which is link to a query and all works ok. What i
want to do is to have a combo box on my invoice form where i can select
different suppliers. This part i can do. The problem lies when i have text
boxs under my combo box so that the text boxes can display values eg address
of the selected supplier from the combo box. I cant seem to link my suppliers
table to my form as my form use's a query
 
N

Nikos Yannacopoulos

Assuming the rowsource of your combo is the Suppliers table, the easiest
way to do it is to read right from the combo! To do that, change its
rowsource property to include the other fields as well (address etc.).
You can specify whether they actually show or not in the listbox by
playing with the column widths property (a column with 0 width doesn't
diplay). This is purely aesthetic, it does not affect the functionality
described here.
Next, use some simple lines of code in the combo's On Change event to
populate the textboxes, simply by reading the values from the combo. The
trick is to reference the combo's columns, like Me.ComboName.Column(1)
etc. Note that the column index is zero-based, so Column(1) is actually
the second one. So, a sample line of code would look something like:

Me.txtAddress = Me.cboCustomers.Column(1)

I suppose my assumptions of control names are self-explanatory.

HTH,
Nikos
 
Top