Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Re: access_asp digest: August 22, 2002


Message #1 by "Raymond Dalton" <rdalton@c...> on Fri, 23 Aug 2002 10:39:34 -0500
In response to:
> I'm trying to find the max number of the "id" column and then write
> to the new recordset for example: "id"+1200. I could use the autonumber,
> but I will be using an option later where so called "active" members
> will be granted a id number from 1 to 1000 and so called "passive"
> members will resume their id as 12000 and above. Then when performing a
> search, and ordering by id, the low numbers will come first.

This is simple code to retrive the highest id value and add one to it for
use as the id in a new row, assuming you are using UserID for your ID field

'open connection to database - you already had this open, so you can add the
other code just under it
    OpenDB sConnUsers2

'create sql text
    SQL_txt = "SELECT TOP 1 UserID FROM Users ORDER BY UserID DESC"
'open recordset
    set rs = sConnUsers2.Execute(SQL_txt)
'acquire last order entered and use it to set new OrderID
    OrderID = rs("OrderID")
'add one to UserID to use in new addrow
    OrderID = OrderID + 1
'close recordset
    rs.close
    set rs = nothing




  Return to Index