I have a table called products but i want to be able to have an order form that has a drop down list of all the products and once selected will add the product and other colums such as unit price etc. How do I do that
I have a table called products but i want to be able to have an order form that has a drop down list of all the products and once selected will add the product and other colums such as unit price etc. How do I do that
Create a form based on that table.
Add a combobox with a row source equal to the product field
Then add code in the after update event to append a new record with that product and any other fields as appropraite
The form will need to be opened in 'ADD new record mode.
I don't think the code needs to append record. Assuming form is bound to OrderDetails table, entry into any bound control such as the combobox will accomplish creating a new record when positioned on New Record row. Code in the combobox AfterUpdate would populate other fields with data from combobox columns. Reference columns by index. Index begins with 0 so if the price is in third column, its index is 2, example:
Me!UnitPrice = Me.cbxProduct.Column(2)
Saving any other data describing the product is likely unnecessary duplication.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
I sort of get the idea however what i have is an order form and a orderdetails table i have added the orderdetails table as a sub-table within my order form. The order form will have my clients details and the sub-table the items they order. the table orderdetails has the following fields customer (relationship to customer table), product (relationship to product table), unit price, markup and price. The field called product is a lookup data type. What i need help with is that if i click on the lookup within the sub-table lets say on the product Milk i would need the unit price, markup and price fields to then get the info from the products table
Tables are not correctly related. The Orders form should have CustomerID, OrderDetails should not have customer info, should have OrderID as foreign key.
Cannot have the required code behind a table, must be a form. The OrderDetails needs to be a form installed as subform on Orders.
Saving UnitPrice and Markup is reasonable because those can change over time. Price, however, is calculated from UnitPrice and Markup and should be calculated when needed, not saved.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.