consecutive default values in table?

B

beejsnyder

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!
 
D

Douglas J. Steele

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!
 
B

beejsnyder

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top