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
|
|||
|
|||
auto increment help please?
No, cannot auto create this number in table design. I have a similar
situation. Here is code similar to what I use. Modified for you because I use 4-digit year. [code]Public Function MyID() MyID = DLast("ID", "Problem11", "Right(ID,2)=" & Right(DatePart("yyyy", Now), 2)) If Len(MyID) 1 Then MyID = Format(Left(MyID, 4) + 1, "0000") & "-" & Right(DatePart("yyyy", Now), 2) Else MyID = "0001-" & Right(DatePart("yyyy", Now), 2) End If "norm" wrote: Is it possible to auto increment a field in a table based on the last 2 digits of year? I am creating a small database for a towing company, and I need to assign each tow job a specific (unique) ticket number. But I need it to be based on year for example: tow 0001-09 0002-09 0003-09 0001-10 0002-10 0003-10 etc.... Is this possible in table design? Thanks in advance for any help! Norm |
#2
|
|||
|
|||
auto increment help please?
On Sat, 9 May 2009 20:42:01 -0700, June7
wrote: No, cannot auto create this number in table design. I have a similar situation. Here is code similar to what I use. Modified for you because I use 4-digit year. [code]Public Function MyID() MyID = DLast("ID", "Problem11", "Right(ID,2)=" & Right(DatePart("yyyy", Now), 2)) If Len(MyID) 1 Then MyID = Format(Left(MyID, 4) + 1, "0000") & "-" & Right(DatePart("yyyy", Now), 2) Else MyID = "0001-" & Right(DatePart("yyyy", Now), 2) End If June, I'd use DMax rather than DLast - DLast returns the last record in *disk storage order*, and that order can be anything that the program finds convenient. It's basically a random record. -- John W. Vinson [MVP] |
Thread Tools | |
Display Modes | |
|
|