Default value
-
- 5StarLounger
- Posts: 736
- Joined: 18 Mar 2010, 11:05
Default value
I'd like to have a field which has a defualt value of the Max of that field +1 (for various reasons, autonumber cannot be used), but just can't seem to get the syntax correct.
-
- Administrator
- Posts: 78574
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Default value
This is not easy to implement in a table, for you aren't allowed to use functions such as DMax in the Default Value property of a field in a table.
But you can do it in a form bound to the table: set the Default Value of the text box bound to the field to
=DMax("name of the field","name of the table")+1
substituting the correct names, of course.
But you can do it in a form bound to the table: set the Default Value of the text box bound to the field to
=DMax("name of the field","name of the table")+1
substituting the correct names, of course.
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 736
- Joined: 18 Mar 2010, 11:05
Re: Default value
Thank you Hans, that's exactly what I was after (sorry, should've said this was on a form).
Trouble is, all I'm getting is '#Name?'.
Here is what I've used;
N.B. this is with 2007, 2003 format.
Trouble is, all I'm getting is '#Name?'.
Here is what I've used;
Code: Select all
=DMax([ID],[tblEquip])+1
-
- Administrator
- Posts: 78574
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Default value
The arguments to DMax should be strings:
=DMax("ID","tblEquip")+1
=DMax("ID","tblEquip")+1
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 736
- Joined: 18 Mar 2010, 11:05
Re: Default value
Ah, so that's all that was wrong; quotes, not square brackets.
Thanks Hans
Thanks Hans