Combinning two table fields to one?

G

Guest

Trucks deliver merchandise to our warehouse. We need to track the date and
the boxes that were delivered by this truck. The same truck makes several
deliveries so it's ID# cannot be used as a unique number. The truck ID and
the date combined, however, can be used as a unique number.

Is there a way to combine the Truck ID# and date to make a unique key field
for the Delivery table? I can combine these values for forms, queries and
reports. If this can't be done, what suggestions do you have for creating a
unique number or should I just set the key field to autonumber?
 
R

Rick Brandt

SharonInGa said:
Trucks deliver merchandise to our warehouse. We need to track the
date and the boxes that were delivered by this truck. The same truck
makes several deliveries so it's ID# cannot be used as a unique
number. The truck ID and the date combined, however, can be used as
a unique number.

Is there a way to combine the Truck ID# and date to make a unique key
field for the Delivery table? I can combine these values for forms,
queries and reports. If this can't be done, what suggestions do you
have for creating a unique number or should I just set the key field
to autonumber?

A primary key (or index) can contain as many as 10 fields. No need to combine
them into a single field.
 
B

Bruce Rusk

Yes BUT what if, one day, the same truck makes two deliveries? That may not
be a possibility now, but what if practices change and it happens some time
in the future? Creating a separate, unique number would preclude such
problems.
 
R

Rick Brandt

Bruce said:
Yes BUT what if, one day, the same truck makes two deliveries? That
may not be a possibility now, but what if practices change and it
happens some time in the future? Creating a separate, unique number
would preclude such problems.

What I said was that you build one primary key that consists of both the truck
ID field and the delivery time field. There is no requirement that the key
consist of only one field.
 
G

Guest

27-2005-1111-01
27-2005-1111-02

Truck number 27
Date 2005-11-11
delivery # 1
delivery # 2
and so on.........
And call it truckdeliveryid or something like that
 

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