| | |
|
|
|
Cry For Help! - Filling In Forms Automatically From Tables |
| message from -elniniol999- on 26 May 2004 |
i have a table called order details which contains:
order id
product id
product name
quantity
unit price
sale price
discount
and a products table containing:
Product id
product name
unit price
units in stock
I have a form which currently shows text boxes for
order id
product id
product name
quantity
unit price
(product id is a combo box)
i can choose the product id from the drop down i have created but it does
not put any other data into any of the other fields.. how on earth EXACTLY
can i manage to do this? i want the data from the product table to fill in
the form once i choose the product id from the form combo box
cheers for ANY help
|
| Duane Hookom replied to -elniniol999- on 25 May 2004 |
If the Product Name will not change (always based on the Product ID) then
there is generally no good reason to save the Product Name in the details
table. Do you have a good reason to save both the Product ID and Product
Name in the details table?
|
| Sabine Oebbecke replied to -elniniol999- on 26 May 2004 |
Your tables are wrongly set up.
Order Table:
|
| Rick Brandt replied to Sabine Oebbecke on 26 May 2004 |
Sorry, but I strongly disagree with this setup. Both Sale Price and
Discount are dynamic values that can (and likely will) change over time.
With your method anyone looking at an Order from a year ago would see
*current* price and discount values, not the values that were in effect at
the time of the Order.
This is a case where it is NOT a breach of normalization principles to copy
the values from the Products table to the Orders table at the time the
Order record is created so the OP was closer to doing it correctly. The
only thing I would set up differently is that the Orders table does need to
have both the ProductID and the ProductName.
To the OP...
Add all of the info you need to the ComboBox for ProductID as additional
columns (they can be hidden if desired). Then in the AfterUpdtae event of
the ComboBox you run code similar to...
Me.Price = Me.ProductID.Column(1)
Me.Discount = Me.ProductID.Column(2)
etc..
I would NOT do the above for ProductName as this does not need to be stored
with your Order. Just have an unbound TextBox with a ControlSource of...
=ProductID.Column(3)
...where the fourth column of the ComboBox contains the ProductName from
the Products table. This will allow the user to *see* the ProductName, but
will not redundantly store it.
|
|
Archived message: Cry For Help! - Filling In Forms Automatically From Tables (Microsoft Access Forms)