consecutive default values in table?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm fixing an existing database. The primary key is a numerical field, consecutive, and the owners would like the next number in line to auto-populate in that field when they enter a new record.

I'm pretty sure this is achieved via default value, but haven't been able to find the proper expression? Tried this: =DMax("[FieldName]","TableName")+1
....and was returned an error message.

Other things that might make a difference: previously created records have since been deleted (when sold) so the list is not complete anymore. Also I'm using MSOffice Professional 2000. Any help in creating the default value expression to just tell the form "this number is the same as the previous record plus 1" would be SO APPRECIATED!
 
AFAIK, it's not possible to set use DMax in setting a field's DefaultValue
in a table.

You can, of course, do this when using a form to update the table, though,
so it shouldn't matter, since you should never be updating tables directly.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



beejsnyder said:
I'm fixing an existing database. The primary key is a numerical field,
consecutive, and the owners would like the next number in line to
auto-populate in that field when they enter a new record.
I'm pretty sure this is achieved via default value, but haven't been able
to find the proper expression? Tried this:
=DMax("[FieldName]","TableName")+1
...and was returned an error message.

Other things that might make a difference: previously created records
have since been deleted (when sold) so the list is not complete anymore.
Also I'm using MSOffice Professional 2000. Any help in creating the default
value expression to just tell the form "this number is the same as the
previous record plus 1" would be SO APPRECIATED!
 
Mr. Steele, you are quite literally my hero!!! Until my next crisis...

Thanks again!!

beejsnyder

Douglas J. Steele said:
AFAIK, it's not possible to set use DMax in setting a field's DefaultValue
in a table.

You can, of course, do this when using a form to update the table, though,
so it shouldn't matter, since you should never be updating tables directly.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



beejsnyder said:
I'm fixing an existing database. The primary key is a numerical field,
consecutive, and the owners would like the next number in line to
auto-populate in that field when they enter a new record.
I'm pretty sure this is achieved via default value, but haven't been able
to find the proper expression? Tried this:
=DMax("[FieldName]","TableName")+1
...and was returned an error message.

Other things that might make a difference: previously created records
have since been deleted (when sold) so the list is not complete anymore.
Also I'm using MSOffice Professional 2000. Any help in creating the default
value expression to just tell the form "this number is the same as the
previous record plus 1" would be SO APPRECIATED!
 
Back
Top