Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to auto fill fields when adding a new record?

Status
Not open for further replies.

malcprice

Technical User
Feb 27, 2002
20
GB
I guess this is easy..... but here goes

I have two tables Company details and sales details

they are related by a field called "companyid".

What I would like to happen is when adding a new sales record in the sales form, You select the company from a combo box and the companyid, country and subsidiary fields are automatically filled in with the details stored in the table called company details.

How is this done? by me.field.value ? or by dlookup?

please help!!!
 
Sounds like you need to use AutoLookup....

Create the form that you want and place a combo box on it.....

Bind the combobox to the many side of the relationship.....i.e. On the Orders/Sales table, not Customer side.....

Place all the other fields on the form, binding them to the One side, i.e. the Customer table, not the Orders/Sales table.....

Then as you change the value in the combo box, the rest will change automatically.....

OR.......

Place all the data you need in a combo box and hide the columns........

Then bind your extra fields to the combo box.......

i.e. Your combo box row source would be SELECT CustomerID, Customer Name, Address, City, County, etc.....

Then each field has it's control source set to =[ComboBoxName].Column(ColumnNumber)......

OR......

Do the same with the combo box and have an after_update event to put the data in the text boxes.....

Enough possibilities???

Hope it helps...

Craig
 
I have tried the first two ways with no joy.

Do you have other suggestions?

I have populated the form by creating a query with information from Company details and sales records. Then put a combo box on the form and binded it to the sales section. THis also has a field that holds the Company name in.

Then added the fields from the company details. With no joy.

The first way you mentioned I just got a blank drop down list?

& The second I got the drop down list but the information did not fill in the new record?

What do you think I am doing wrong?

Many thanks for your answer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top