A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

2 digits year with 3 digits



 
 
Thread Tools Display Modes
  #1  
Old June 14th, 2005, 11:37 PM
Mike
external usenet poster
 
Posts: n/a
Default 2 digits year with 3 digits

I'm creating a table with a field call tracking but the data type not
allowing me to customize that field. I like to see this automaticly every
time a new record is enter.

05001
05002
.........
05009
0500A
.......
0500Z
The first two digits are year

Please help.

Thanks


  #2  
Old June 14th, 2005, 11:54 PM
KARL DEWEY
external usenet poster
 
Posts: n/a
Default

Set the Default of your TextField to ---
=Right(Year(Date()),2)

"Mike" wrote:

I'm creating a table with a field call tracking but the data type not
allowing me to customize that field. I like to see this automaticly every
time a new record is enter.

05001
05002
........
05009
0500A
......
0500Z
The first two digits are year

Please help.

Thanks


  #3  
Old June 15th, 2005, 06:39 PM
Tim Ferguson
external usenet poster
 
Posts: n/a
Default

"=?Utf-8?B?TWlrZQ==?=" wrote in
:

I'm creating a table with a field call tracking but the data type not
allowing me to customize that field. I like to see this automaticly
every time a new record is enter.

05001
05002


For a start it's really not a good idea to combine these two separate
bits of information into a single field. If you "like to see" it looking
like that, then it's not hard to arrange it in a control on a form or a
report.

You need two fields, and integer called YearNum and a text field called
"SerialCode". It would be simpler to have the serial number wrapping from
009 to 010 rather than 00A, but including the letters just takes a little
bit more code.

You also need to make sure that you can control all record creation, and
manage this with code behind a form. No table datasheets, no Excel, no
append queries etc. The code would need to do something like:

' pick the right year somehow
' if it's already in a text box you can read it from there,
' otherwise hack it out of today's date...
sqlCriterion = "YearNum = " & Format(Year(Date()) Mod 100, "00")

' get the largest one so far
varMaxSerial = DMax("SerialNum", "MyTable", sqlCriterion)

' see if it got any answer
If IsNull(varMaxSerial) Then
' no; put a zero in the text box
me!txtSerialNum = "000"

else
' yes: increase the value by one before putting it in
' you can probably write your own function to increment the
' text string
Me!txtSerialNum = NextSerialNumber(varMaxSerial)

End If



For more information, try googling for Access Custom Autonumbers. There
is good code on Dev Ashish's site http://www.mvps.org/access/ and lots of
other places. Note too that this is not strictly safe for multiuser
setups, if there is a chance that two users may be creating a record at
the same time.

Hope that helps


Tim F

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding +1 every year. Joshy General Discussion 4 March 22nd, 2005 01:33 PM
Getting Fiscal Year instead of Calendar Year Keena Setting Up & Running Reports 1 October 1st, 2004 02:55 PM
Show last year first, but keep data sorted cronologically Bob Richardson General Discussion 11 July 22nd, 2004 10:00 PM
Add a FIXED MONTH and DAY with the CURRENT YEAR texcel General Discussion 1 June 23rd, 2004 01:36 AM
date conversion web_time Worksheet Functions 10 December 25th, 2003 06:51 PM


All times are GMT +1. The time now is 08:55 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.