JuzMaintain
New member
- Local time
- Today, 13:30
- Joined
- Feb 8, 2011
- Messages
- 2
New here, so if I posted in the wrong forum, please to forgive. 
Here is the question in a nutshell: How do you have duplicate entries for a primary key made up of two foreign keys when the data type is an autonumber field in Access 2007? If possible, does it require the use of VBA code or can it be done with a query?
I'm trying to store multiple items into a single record on a junction table (tbl SalesOrderDetail) that uses the primary keys from two other tables (SalesOrderID from tbl Sales Orders and ProductID from tbl Inventory). I have the data type of SalesOrderID from tbl SalesOrders being generated as an autonumber field then being stored in the junction table as one half of the primary key in a number data type field, do-able so long as both fields have long integer field sizes, which they do.
I want to be able to generate the autonumber from SalesOrderID on tbl SalesOrders and have it remain static in tbl SalesOrderDetail in order to be able to store multiple items from the inventory onto a single sales record with that number in the junction table. My assumption is that because tbl SalesOrders is generating the autonumber and tbl SalesOrderDetail is storing it as a general, static number that it will NOT re-increment upon said storage to the junction table but merely store the already generated autonumber.
I also want to mirror this exact scenario on the purchasing side.
Basically, I'd like to tie this situation (both sales and purchasing) to corresponding data entry forms that, when opened, snap to the next autonumber in the sequence at the top of the form, along with the general details like date, customer ID, etc., and allow the user to enter the product details in a continuous datasheet subform below that that is linked to the junction table via either a query, VBA code or some other mojo I'm unaware of and populate tbl SalesOrderDetail consistently in the above stated manner.
Will this keep the records simple, neat and clean or will it create a clusterf*ck? Is there an easier way to tie multiple inventory items to a single sales/purchase record in Access 2007?
Thanks for any help...
SA
Los Angeles, CA

Here is the question in a nutshell: How do you have duplicate entries for a primary key made up of two foreign keys when the data type is an autonumber field in Access 2007? If possible, does it require the use of VBA code or can it be done with a query?
I'm trying to store multiple items into a single record on a junction table (tbl SalesOrderDetail) that uses the primary keys from two other tables (SalesOrderID from tbl Sales Orders and ProductID from tbl Inventory). I have the data type of SalesOrderID from tbl SalesOrders being generated as an autonumber field then being stored in the junction table as one half of the primary key in a number data type field, do-able so long as both fields have long integer field sizes, which they do.
I want to be able to generate the autonumber from SalesOrderID on tbl SalesOrders and have it remain static in tbl SalesOrderDetail in order to be able to store multiple items from the inventory onto a single sales record with that number in the junction table. My assumption is that because tbl SalesOrders is generating the autonumber and tbl SalesOrderDetail is storing it as a general, static number that it will NOT re-increment upon said storage to the junction table but merely store the already generated autonumber.
I also want to mirror this exact scenario on the purchasing side.
Basically, I'd like to tie this situation (both sales and purchasing) to corresponding data entry forms that, when opened, snap to the next autonumber in the sequence at the top of the form, along with the general details like date, customer ID, etc., and allow the user to enter the product details in a continuous datasheet subform below that that is linked to the junction table via either a query, VBA code or some other mojo I'm unaware of and populate tbl SalesOrderDetail consistently in the above stated manner.
Will this keep the records simple, neat and clean or will it create a clusterf*ck? Is there an easier way to tie multiple inventory items to a single sales/purchase record in Access 2007?
Thanks for any help...
SA
Los Angeles, CA