Autonumber and Multiple-Field Keys

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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.
 
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.
 
Back
Top