Autonumber

  • Thread starter Thread starter RH
  • Start date Start date
R

RH

Hi all
I have a form on the internet that needs to generate the next number in a
sequence for a member number. I know not to use AutoNumber, but I wanted to
know if I could use DMAX from the internet.

I believe the syntax to use within Access is
=DMAX("FieldName","TableName")+1

How would I translate this to work from a web form?

TIA
Robyn
 
You can use an Autonumber, but it's not guaranteed to be sequential. If you
want a sequential number, do something like this:

Dim rst, con, NewNum

set con = Server.CreateObject("ADODB.Connection")
set rst = Server.CreateObject("ADODB.Recordset")

con.Open "YourConnectString"
rst.Open "SELECT Max(YourIdField) As MaxNum FROM YourTable", con

If Not(rst.EOF and rst.BOF) Then
NewNum = rst("MaxNum") + 1
Else
NewNum = 1
End If

con.Close
rst.Close
 
Thanks - that looks good.
what happens tho if I have a couple of people working on the web at the same
time, how do I make sure they don't both grab the same number?
Again Thanks
Robyn
 
Back
Top