Follow via:
RSS
Email Alert
Question
0 Votes
+ -

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

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
26th Nov 2011

Answers (1)

-1 Votes
+ -
A better question would be why bother, but
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

e.g.
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)
26th Nov 2011
Answer the question
Formatting +
BB Codes - Note: HTML is not supported in forums
  • [b] Bold [/b]
  • [i] Italic [/i]
  • [u] Underline [/u]
  • [s] Strikethrough [/s]
  • [q] "Quote" [/q]
  • [ol][*] 1. Ordered List [/ol]
  • [ul][*] · Unordered List [/ul]
  • [pre] Preformat [/pre]
  • [quote] "Blockquote" [/quote]

Join the TechRepublic Community and join the conversation! Signing-up is free and quick, Do it now, we want to hear your opinion.