"home" <re**@telkomsa.net> wrote in message
news:bo**********@ctb-nnrp2.saix.net...
Hi I wonder if someone can help.
I have a form that has a combo box that I use to select a customer. Ho do I
populate other fields on my form based on the value I have selected from the
conbo box. I want access to put the client details in automatically.
Actually, in most circumstances you would not want to do this. You would
instead use a subform, query, or other lookup method so that when looking at the
record you *see* all of the customer details, but only store the CustomerID
value that you entered from the ComboBox.
If this were a Sales Order for example, you have already stored the Customers
information once (where it belongs) in the Customers table. Why copy that data
over for every Order record. If you do that then any time your customer's data
changes, the data in all previous Orders is now incorrect.
I would recommend one of the following methods to display the details. If it is
going to be all clumped together somewhere on the form (which is typical), then
create a small sub-form with the details like Address, phone, etc.. and add it
to your current form using the CusotmerID field as the Master/Child Link.
Whenever you change the CustomerID then you will automatically see that
customer's *current* data.
If you need to disperse the detail data around on your form then add all of the
columns you need to the ComboBox you currently have (you can make them hidden if
you like). Then add TextBoxes to the form with ControlSource properties similar
to...
=CustomerComboBox.Column(1)
=CustomerComboBox.Column(2)
etc..
Columns in ComboBoxes are numbered starting with zero so the above examples are
actually going to display the data in the second and third columns respectively.
Now; if for some reason you actually did want to store the details every time
because you wanted a record of "the company details at the point in time when
the record was created", then you would use a variation on the second method
above. You would bind your other TextBoxes to fields in your table and in the
AfterUpdate event of the ComboBox use code similar to...
Me!CustomerCity = Me!CustomerComboBox.Column(1)
Me!CustomerState = Me!CustomerComboBox.Column(2)
etc..
This method grabs the data from the hidden columns and inserts it into your
bound TextBoxes so it will be saved with each record.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com