Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generate an unique code from different fields

Status
Not open for further replies.

firsttime

Technical User
Oct 1, 2002
22
0
0
NL
Hi,

I have a table that called 'Title'. I have made a form with fields from the ' Title' table. In one field i want to put a code. This code must exist the following things: a date, the first two letters from the field Theme, the first letter from the AuthorLastName, the first letter form the AuthorFistname and the TitelID.

All these fields are in the table "Title"
Example:

Date: 02-07-2003
Theme: Thriller
AuthorLastName: King
AuthorFistname: Stephen
TitelID:1

So the code should be like this: 20030702ThKS001

Is it possible? Can i also put underscoll or a point in it.
like this: 20030702_Th_K.S.001

THX IN ADVANCE

Dan
 
Set the control source for the field to

=Format([DateField],"yyyymmdd") & "_" & Left([Theme],2) & "_" & left([AuthorLastName],1) & "." & left([AuthorFirstName],1) & "." & format([TitleID],"000")

Good Luck
 
Hi Savil,

Just tested and it works!!!

Thx a lots.

Dan
 
Hi,

I tried to use this code at home with Access 2000. It works fine. But at my work i have Access 97. When i want to put this code in Access 97 , it gives an error.

"The expression you entered contian invalid syntax.
You omitted an operand or operator, you entered an invalid character or comma, or you entered text without surrounding it in quotation marks."

Can anyone help me with this?

Dan
 
That code works in Access97, just copy it from above and paste it into your field
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top