Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Still needing help with numbering


Message #1 by "Paul Price" <pprice@o...> on Thu, 29 Aug 2002 17:36:24
I need to create an ID number formatted like 02-0001. This will be a job a 
non-duplicating job number with the 02 part being the year and the rest of 
the number needs to start over with 0001 on January 1 of the new year. 
I'll be entering multiple records in each day so using the julian date 
wont work. 
I'm really new at this and can't seem to find anything similar in any 
books I've read so any help I get will be much appreciated.

Paul
Message #2 by "Zimmer Computer Consulting" <zee@t...> on Thu, 29 Aug 2002 13:45:26 -0700
I meant to follow up on my earlier message. I'm sorry I misunderstood your
problem -- I have been working with file names with dates lately.

Basically, you would set up a "control" database table with a field called
"LastTransNum" and when you need a unique serial or transaction number, you
get the old value from the database table, increment it by one, and then
save the new value back to the control database.

This is the process, which is to store the last used transaction number.

Do you need some help coding this?

-- Zee



----- Original Message -----
From: Paul Price <pprice@o...>
To: Access ASP <access_asp@p...>
Sent: Thursday, August 29, 2002 5:36 PM
Subject: [access_asp] Still needing help with numbering


> I need to create an ID number formatted like 02-0001. This will be a job a
> non-duplicating job number with the 02 part being the year and the rest of
> the number needs to start over with 0001 on January 1 of the new year.
> I'll be entering multiple records in each day so using the julian date
> wont work.
> I'm really new at this and can't seem to find anything similar in any
> books I've read so any help I get will be much appreciated.
>
> Paul


Message #3 by "Zimmer Computer Consulting" <zee@t...> on Thu, 29 Aug 2002 14:11:18 -0700
    ''' Preliminaries
    ''' adCmdText must be defined for use below

    ''' DSN string and Open the ADO connection object
    DatabaseDSN = "DSN=MyDSN;UID=Admin;PWD=Admin"
    Set DatabaseConnection = Server.CreateObject( "ADODB.Connection" )
    DatabaseConnection.Open DatabaseDSN


    ''' SAMPLE ASP -- USING A CONTROL DATABASE


   ''' Database Tables
   ControlTable = "[Company Control]"

    ''' Arrays for saving data changes
    dim ControlField(0)
    dim ControlValue(0)

    ''' Instantiate Control database recordset object
    Set ControlRecordset = Server.CreateObject( "ADODB.Recordset" )
    ControlRecordset.CursorType = adOpenKeyset
    ControlRecordset.LockType = adLockOptimistic

    ''' Retrieve the Control recordset with the SQL query
    ''' (Make sure adCmdText is defined)
    ControlQuery = "SELECT * FROM " & ControlTable
    ControlRecordset.Open ControlQuery, DatabaseConnection, , , adCmdText

    ''' Get the last number used and calculate next and future starting
numbers
    LastTransNum = ControlRecordset.Fields( "LastTransNum" )
    NextTransNum = LastTransNum + 1

     ''' Save the updated number back to database
    ControlField(0) = "LastTransNum"
    ControlValue(0) = NextTransNum
    ControlRecordset.Update ControlField, ControlValue

    ''' Close and deinstantiate the Control recordset
    ControlRecordset.Close
    set ControlRecordset = Nothing



    ''' REST OF ASP CODE HERE


    ''' Close and deinstantiate connection
    DatabaseConnection.Close
    set DatabaseConnection.Close



-------------------


----- Original Message -----
From: Paul Price <pprice@o...>
To: Access ASP <access_asp@p...>
Sent: Thursday, August 29, 2002 5:36 PM
Subject: [access_asp] Still needing help with numbering


> I need to create an ID number formatted like 02-0001. This will be a job a
> non-duplicating job number with the 02 part being the year and the rest of
> the number needs to start over with 0001 on January 1 of the new year.
> I'll be entering multiple records in each day so using the julian date
> wont work.
> I'm really new at this and can't seem to find anything similar in any
> books I've read so any help I get will be much appreciated.
>
> Paul



  Return to Index