Autonumber and Multiple-Field Keys

D

Dorci

Is it possible to use autonumber to generate a multiple-field key? For example:

OrderID = 123 ProductID = 1
OrderID = 123 ProductID = 2
OrderID = 124 ProductID = 1
OrderID = 124 ProductID = 2
OrderID = 124 ProductID = 3

In this example, Orders and Products are two tables with a one-to-many relationship. I'd like the ProductID number to be generated by autonumber, but it would have to restart at 1 for each OrderID.
 
G

Gerald Stanley

The sutonumber datattype should only be used for generating
unique row ids where the value is of no importance. This
is not the case in your app so you will have to find
another means of generating the product id

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
Is it possible to use autonumber to generate a
multiple-field key? For example:
OrderID = 123 ProductID = 1
OrderID = 123 ProductID = 2
OrderID = 124 ProductID = 1
OrderID = 124 ProductID = 2
OrderID = 124 ProductID = 3

In this example, Orders and Products are two tables with a
one-to-many relationship. I'd like the ProductID number to
be generated by autonumber, but it would have to restart at
1 for each OrderID.
 
L

Laurie

You can write simple code to create the productid. You
will store the last used number for each orderid in a
lookup table. Then check that last used number to
generate the new number. Hook this code onto your SAVE
RECORD function.
-----Original Message-----
Is it possible to use autonumber to generate a multiple- field key? For example:

OrderID = 123 ProductID = 1
OrderID = 123 ProductID = 2
OrderID = 124 ProductID = 1
OrderID = 124 ProductID = 2
OrderID = 124 ProductID = 3

In this example, Orders and Products are two tables with
a one-to-many relationship. I'd like the ProductID number
to be generated by autonumber, but it would have to
restart at 1 for each OrderID.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top