You need to be querying for the maximum value in whatever table it is in
which you're storing the records.
If you're always querying NewProjectNumber_Table, but never updating the
value there, it's always going to return the same value to you.
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
OK, Now I have it partially working. I created a table called
NewProjectNumber_Table and it has only one field called NewProject
Number.
I
set the number to 260001. This is the only record in this table. When
I
run
my form it will create a new project number, 260002 which appears to be
OK.
However when I create a second project it gives it the same number. I
was
expecting my table called NewProjectNumber to be updated to 260002 so
when
I
went to create another project it would generate the number 260003.
This
is
not what is happening.
Am I missing a step or am I expecting too much from access?
Thanks again for your help.
:
Because of the spaces in your names, you need square brackets:
Me!Project Number = Nz(DMax("[Project Number]","[Project_Number
Table]"),0)+1
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Me!Project Number = Nz(DMax("Project Number","Project_Number
Table"),0)+1
Perhaps this is my problem...I have Project Number as the field in
my
main
form that I'm trying to update and Project Number in a table called
Project_Number Table where I'm trying to keep my next available
number.
Thanks again.
:
What's the exact code you've got (copy-and-paste it into your
reply,
as
opposed to retyping it)
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
When I use this formula (I'm putting the code at the "ON ENTER"
of
the
field
for Project Number), I get the following error
Compile Error
Expected =
so still no luck in getting this to work.
Thanks for your continued help.
:
Douglas J. Steele wrote:
Unfortunately, Joseph made a typo.
Who me? Well I never! ...
Well maybe ...
Thanks for the correction, I am sure it would have taken
me
forever
to
notice it.
It should be:
Me!NameOfField = Nz(DMax("YOURFIELDNAME","TABLENAME"), 0) +
1
where NameOfField is the name of the field that's supposed
to
hold
the
value.