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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
"=?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 | |
|
|
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 |