How to create a unique string from other fields

G

Greyman

Hello,

I am trying to create a (uniquie) string of text and numbers built from text
& numbers from different fields in a table:

e.g. Date = 18/05/2009, Room = A, Buliding = 33, Area = 26

so my new string would = 180509A3326

I know I have done this in the past (about 10 years ago!) and I'm having
trouble remembering what to do ..............trouble with grey matter!

All help appreciated.

Cheers
 
S

Stefan Hoffmann

hi,
I am trying to create a (uniquie) string of text and numbers built from text
& numbers from different fields in a table:
Why do you need this to do?
e.g. Date = 18/05/2009, Room = A, Buliding = 33, Area = 26

so my new string would = 180509A3326
As a new field in a query:

[Key]: Format([Date], "ddmmyyyy") & [Room] & [Building] & [Area]

btw, it is not unique. E.g.

Date = 18/05/2009, Room = A, Buliding = 3, Area = 326

gives the same key.


mfG
--> stefan <--
 
J

John W. Vinson

Hello,

I am trying to create a (uniquie) string of text and numbers built from text
& numbers from different fields in a table:

e.g. Date = 18/05/2009, Room = A, Buliding = 33, Area = 26

so my new string would = 180509A3326

I know I have done this in the past (about 10 years ago!) and I'm having
trouble remembering what to do ..............trouble with grey matter!

All help appreciated.

Cheers

Storing this information redundantly would be generally A Very Bad Idea. Not
only is it not unique, as Stefan points out, it's pretty pointless! If you
want to create a unique index on the four fields, you can - it is not
necessary to store the same information redundantly in a composite field to do
so.

If you want this just for display purposes, do it in a query:

Format([datefield], "ddmmyy") & [Room] & [Building] & [Area]

but as a rule there would be no good reason to store this.
 

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