Then
Me.[Quote Number] = Nz(DMax("[Quote Number]", "[YourTable]"),0)+1
Else
Me.[Quote Number] = 0
End If
This will work fine in a single-user environment, but in a multi-user
environment then two or more users could be adding records simultaneously, in
which case they'd get the same number. In normal circumstances where
sequential numbers are generated for every record the Quote Number field
would be indexed uniquely and the index violation error could be handled to
overcome this. This can be done if the non-quote rows have Null quote
numbers but if you are using zeros for these then you can't index the field
uniquely. There are other methods you can use to prevent duplication,
however, one being to store the last used number in a separate databse on the
server and open this uniquely to get the next number. Only one user can get
the next number at any one time therefore. A user could get a number and
then abandon it or delete the record of course in which case the sequence
would be broken as the number would not be reused, as is the case when a true
autonumber is used.
I have posted a demo of how incrementing numbers can be generated in this
way at the following link. It also allows for the starting number of the
sequence to be reset.
http://community.netscape.com/n/pfx...libraryMessages&webtag=ws-msdevapps&tid=23839
Ken Sheridan
Stafford, England