470,647 Members | 1,197 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,647 developers. It's quick & easy.

default set to 'max+1'

Hey folks -

I have a field that is a number. For new records, I want it to default to
the highest value of that field +1. What is the syntax for the default
value?

Steve Lefevre
Nov 12 '05 #1
1 2238
Steve Leferve wrote:
Hey folks -

I have a field that is a number. For new records, I want it to default to
the highest value of that field +1. What is the syntax for the default
value?

Steve Lefevre

If an autonumber's no good for you (and it's no good for anyone but the
machine!!!) then don't ever use a default value in this way, two people
open the form and add a record they'll get the same number, horrendous
results.

Use a BeforeUpdate procedure, e.g.

(air code)
Sub Form_BeforeUpdate(Cancel As Integer)
If isnull(MySeqNo) Then
MySeqNo = Nz(DMax("MySeqNo","MyTable"),0)+1
end if
End Sub

--
But why is the Rum gone?
Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

18 posts views Thread by Klaus Alexander Seistrup | last post: by
2 posts views Thread by Sheila King | last post: by
41 posts views Thread by JKop | last post: by
2 posts views Thread by Lauren Quantrell | last post: by
3 posts views Thread by ose | last post: by
3 posts views Thread by mcolson | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.