How do I automate generation of a Date Code from =Date() in MS-Access 2007?

By mwulse ·
We are using a date code to help facilitate FIFO inventory control. When a user performs a transaction, we need the date code automatically generated in the DateCode field of the form. Date code consists of, for the current date, :

Year = A single alpha character
2011 = A, 2012 = B, 2013 = C, etc.
Month = A sigle alpha character
Jan = A, Feb = B, Mar = C, etc.
Day = Two character representation
1 = 01, 2 = 02 - 10=10, etc.

Example: March 8, 2012 = BC08

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

A better question would be why bother, but

by Tony Hopkinson In reply to How do I automate generat ...

you could do it with a calculated field, it's jus a big bunch of vb (or sql functions)
So if the date you are building the code from is TransactionDate

Year(TransactionDate) = 2012
2012 - 2011 = 1
A is ascii 65
B is chr(65 + 1)

Ad nauseum.
So in VB it's Year, Month and Day (I think), In SQL it's DatePart for the parts of your date
Chr in SQl would be a convert(Char,SomeValue)

Related Discussions

Related Forums