By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,841 Members | 1,704 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,841 IT Pros & Developers. It's quick & easy.

Default Max value plus one

P: n/a
In my form, I am trying to set up a field so that its default is the
max of that field + 1. I have gone to my form, design view and
clicked on the data tab. From there I clicked on the elipses next to
default value and built an expression. Here is what the expression
builder has given me.

=Max([AssetNumber])+1

It seems to always think that Max([AssetNumber]) is 0. In the table
design view, I have the default value set to 0. I can't seem to
change that to be based upon other values in the field.

Does what I'm asking for make sense?

Thanks for any help you can give,

Matt
Dec 7 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"mcolson" <mc*********@gmail.comwrote in message
news:6d**********************************@w56g2000 hsf.googlegroups.com...
In my form, I am trying to set up a field so that its default is the
max of that field + 1. I have gone to my form, design view and
clicked on the data tab. From there I clicked on the elipses next to
default value and built an expression. Here is what the expression
builder has given me.

=Max([AssetNumber])+1

It seems to always think that Max([AssetNumber]) is 0. In the table
design view, I have the default value set to 0. I can't seem to
change that to be based upon other values in the field.

Does what I'm asking for make sense?

Thanks for any help you can give,

Matt
The DMAX() function may work. But it will slowdown paging between records.
Also if this is a multi-user system, more then one user may get the same
default value.
Dec 7 '07 #2

P: n/a
mcolson wrote:
>In my form, I am trying to set up a field so that its default is the
max of that field + 1. I have gone to my form, design view and
clicked on the data tab. From there I clicked on the elipses next to
default value and built an expression. Here is what the expression
builder has given me.

=Max([AssetNumber])+1

It seems to always think that Max([AssetNumber]) is 0. In the table
design view, I have the default value set to 0. I can't seem to
change that to be based upon other values in the field.

A common approach is to use DMax in the form's BeforeUpdate
event procedure. E.g.

Me.AssetNumber = Nz(DMax("AssetNumber", "thetable"),0)+1

The BeforeUpdate event presents a very small window for a
collision.

--
Marsh
Dec 8 '07 #3

P: n/a
On Dec 7, 4:05 pm, "paii, Ron" <n...@no.comwrote:
"mcolson" <mcolson1...@gmail.comwrote in message

news:6d**********************************@w56g2000 hsf.googlegroups.com...
In my form, I am trying to set up a field so that its default is the
max of that field + 1. I have gone to my form, design view and
clicked on the data tab. From there I clicked on the elipses next to
default value and built an expression. Here is what the expression
builder has given me.
=Max([AssetNumber])+1
It seems to always think that Max([AssetNumber]) is 0. In the table
design view, I have the default value set to 0. I can't seem to
change that to be based upon other values in the field.
Does what I'm asking for make sense?
Thanks for any help you can give,
Matt

The DMAX() function may work. But it will slowdown paging between records.
Also if this is a multi-user system, more then one user may get the same
default value.
The DMax() worked great. I'm not worried about multiple people
accessing the database in this case. Only one person will be adding
to the table. This works better than using an Autonumber for me,
because I would like the opportunity to skip some values.
Dec 10 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.