Hi,
I am currently designing a database table for our order intake. I hjave a
field called ProductID, what I'm trying to do is after I select the correct
ProductID from the drop down menu, I then want the ProductName & ProductPrice
to automatically update. Being a ' newbie ' I have no experience of access.
thanks.
Well, you're making a very typical "newbie" mistake.
Your Orders table should have the ProductID in it. You should
certainly NOT copy the ProductName field into the Orders table!
As a relational database, Access follows the "Grandmother's Pantry
Principle": "a place - ONE place! - for everything, everything in its
place". If you need the product name associated with an order, you
would use a *query* to link to the Products table to pick it up.
Storing the name in the order table is redundant and unnecessary.
The price is a somewhat different issue. Since prices can change, you
really do want to capture the price *as it existed at the time of the
order*. To do so you need to use a little bit of VBA code; in the
AfterUpdate event of the product combo box, you can "push" the product
price into a form control for the order price field:
Private Sub cboProductID_AfterUpdate()
Me!txtProductPrice = cboProductID.Column(2)
End Sub
where txtProductPrice is the name of the textbox bound to the order
price field, cboProductID the name of the Product dropdown box, and
the (2) means the *third* column in the combo box: it's zero based.
Have you looked at the Northwind sample database Orders form? It's not
perfect but it demonstrates quite a few worthwhile features.
John W. Vinson[MVP]