Create an ID based on two fields

  • Thread starter Access Beginner
  • Start date
A

Access Beginner

i have deliveries leaving my office every day and each delivery leaves with a
report to which we wish to assign an id based on the location and delivery
date i have a combo box and text box for selecting the office and delivery
date and i wish to combine the two as below

OFFICE FIELD = OFFICENAME
SHORTENED TO 4 CHAR = OFFI
DATE FIELD = 13/01/09
SHORTENED TO = 130109

LEAVING RESULTINGFIELD = OFFI130109

I Need do do all of this one one click any help btw the resulting field will
be unbound as i already have worked out the script to append it to all
delivery items
 
J

John Spencer (MVP)

YOu want to use the expression
nLEFT([Office field],4) & FORMAT([Date Field],"ddmmyy")

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
J

John Spencer (MVP)

Whoops! Got an extra letter in that expression.

You want to use the expression
LEFT([Office field],4) & FORMAT([Date Field],"ddmmyy")

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
YOu want to use the expression
nLEFT([Office field],4) & FORMAT([Date Field],"ddmmyy")

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

Access said:
i have deliveries leaving my office every day and each delivery leaves
with a report to which we wish to assign an id based on the location
and delivery date i have a combo box and text box for selecting the
office and delivery date and i wish to combine the two as below
OFFICE FIELD = OFFICENAME
SHORTENED TO 4 CHAR = OFFI
DATE FIELD = 13/01/09
SHORTENED TO = 130109

LEAVING RESULTINGFIELD = OFFI130109

I Need do do all of this one one click any help btw the resulting
field will be unbound as i already have worked out the script to
append it to all delivery items
 
J

John W. Vinson

i have deliveries leaving my office every day and each delivery leaves with a
report to which we wish to assign an id based on the location and delivery
date i have a combo box and text box for selecting the office and delivery
date and i wish to combine the two as below

OFFICE FIELD = OFFICENAME
SHORTENED TO 4 CHAR = OFFI
DATE FIELD = 13/01/09
SHORTENED TO = 130109

LEAVING RESULTINGFIELD = OFFI130109

Sorry, but that is a Really Really Bad Idea.

It would prevent you from ever making two deliveries on one day, even a rush
emergency delivery.

It would prevent you from having two offices which happen to have the same
first four letters: "Winchester" and "Wincombe" say.

Storing data in a key is incorrect design; storing data redundantly is
incorrect design; storing two pieces of information in one field is incorrect
design!

If you need to know the date... use the DeliveryDate field in your table. If
you need to know the destination... use the Office field in your table. It's
not necessary nor beneficial to encode that information in an ID field!
 

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