|
 |
access_asp thread: Creating Unique Incremental Number
Message #1 by "Paul Price" <pprice@o...> on Mon, 26 Aug 2002 20:34:41
|
|
I need to create a unique incremental number formatted 02-0001. 02 being
the current year and the number starting over at 0001 on the first day of
each year. Any suggestions?
Paul
Message #2 by "Zee Computer Consulting" <zee@t...> on Mon, 26 Aug 2002 18:12:47 -0700
|
|
Try something like this:
FUNCTION TodayUniqueString()
' Get today's date and make a string
TodayDate = date()
' Extract the year
YearString = cStr( Year( TodayDate ) )
' Create start of year string
StartDate = cDate( "01/01/" & YearString )
' Calculate the number of days from start of year
DayCount = DateDiff( "d", TodayDate, StartDate ) + 1
' Create zero-packed day count string
DayString = right( "0000" & DayCount, 4 )
' Return today's date string
TodayUniqueString = right( YearString, 2 ) & "-" & DayString
FUNCTION END
-- Zee
----- Original Message -----
From: "Paul Price" <pprice@o...>
To: "Access ASP" <access_asp@p...>
Sent: Monday, August 26, 2002 8:34 PM
Subject: [access_asp] Creating Unique Incremental Number
> I need to create a unique incremental number formatted 02-0001. 02 being
> the current year and the number starting over at 0001 on the first day of
> each year. Any suggestions?
>
> Paul
>
Message #3 by "Paul Price" <pprice@o...> on Tue, 27 Aug 2002 16:53:20
|
|
Thanks Zee, I'm new at this so this has gotten me a lot closer than I
could've gotten on my own. The only thing is this number needs to be
incremental and unique. This is giving me the same value for each record I
enter (on the same day?). This number is a job number by the way. Any
ideas?
> Try something like this:
FUNCTION TodayUniqueString()
' Get today's date and make a string
TodayDate = date()
' Extract the year
YearString = cStr( Year( TodayDate ) )
' Create start of year string
StartDate = cDate( "01/01/" & YearString )
' Calculate the number of days from start of year
DayCount = DateDiff( "d", TodayDate, StartDate ) + 1
' Create zero-packed day count string
DayString = right( "0000" & DayCount, 4 )
' Return today's date string
TodayUniqueString = right( YearString, 2 ) & "-" & DayString
FUNCTION END
-- Zee
----- Original Message -----
From: "Paul Price" <pprice@o...>
To: "Access ASP" <access_asp@p...>
Sent: Monday, August 26, 2002 8:34 PM
Subject: [access_asp] Creating Unique Incremental Number
> I need to create a unique incremental number formatted 02-0001. 02 being
> the current year and the number starting over at 0001 on the first day of
> each year. Any suggestions?
>
> Paul
>
|
|
 |