DISPLAY NEXT RECORD NUMBER

S

Scuda

Hello all, I tried searching for this but could not find a solution.

What I am trying to do is have a text box that DISPLAYS my next number for
something. It is ONLY for display.

My field is SENE_CASE_num and my table is tblSENESarLog. I tried the
following but it did not work, I tried it in my Control Source as well as my
default value.

=DMax("SENE_CASE_num","tblSENESarLog")+1

Can anyone tell me what I am doing wrong? Thanks in advance!
 
M

Marshall Barton

Scuda said:
Hello all, I tried searching for this but could not find a solution.

What I am trying to do is have a text box that DISPLAYS my next number for
something. It is ONLY for display.

My field is SENE_CASE_num and my table is tblSENESarLog. I tried the
following but it did not work, I tried it in my Control Source as well as my
default value.

=DMax("SENE_CASE_num","tblSENESarLog")+1

Can anyone tell me what I am doing wrong?


That should do exactly what you said. What makes you think
"it did not work"?

There may be a confusing point about this kind of thing in
the DefaultValue property when you are creating a new record
with a new max value for the SENE_CASE_num field. Until the
new record has been saved, the max value in the table will
not be changed. Furthermore, the expression in a
DefaultValue property is not evaluated until the first
character is entered a control.

When you use that ecpression in a text box's ControlSource
property the text box's expression is not automatically
reevaluated (because it has no dependency on another
control). In this situation, you need to force it to
recalculated the value when the table is updated. You can
do this in the form's AfterUpdate event:
Me.thetextbox.Recalc
 
S

Scuda

Thanks Marshall, but I had an error with: Me.txtNext_ucn.Recalc when I
debugged.

I should also mention that my prev problem gave me a #error. Also, and I
don't think this matters btu the form I wanted to display this on, is not the
form where it is primarily used. That shouldn't matter as long as that same
table is my record source right?

Thanks again.
 
K

K

What do you mean by "something" Is "My next number" a value or record?

Scuda said:
Thanks Marshall, but I had an error with: Me.txtNext_ucn.Recalc when I
debugged.

I should also mention that my prev problem gave me a #error. Also, and I
don't think this matters btu the form I wanted to display this on, is not the
form where it is primarily used. That shouldn't matter as long as that same
table is my record source right?

Thanks again.
 
S

Scuda

Sorry. It is a text box that is linked to a record in my table. It is a Case
number, that each record I create has it's own seq number.

Thanks!

K said:
What do you mean by "something" Is "My next number" a value or record?

Scuda said:
Thanks Marshall, but I had an error with: Me.txtNext_ucn.Recalc when I
debugged.

I should also mention that my prev problem gave me a #error. Also, and I
don't think this matters btu the form I wanted to display this on, is not the
form where it is primarily used. That shouldn't matter as long as that same
table is my record source right?

Thanks again.
 
K

K

Is the case number Linked (Relationship) between the sequential numbers that
apply? If so, you could just create a query that shows all the sequntial
records that pertain to each case number, then merge the query into a form
designed has a datasheet and insert into the form to be displayed
 
S

Scuda

K, the case number is the seq number. It is not an autonumber but instead one
I created. It is a text box in my table.

Thanks.
 
K

K

Even if the case number is not an auto number and as long as it it unique you
can still set it has primary and link to other tables. In the other tables
you will need to create a feild with the case number so you create a
relationship.

As far as I can see is that you need someway to link the case number to
other related records in order to do any programming or else how would the
program be able to idetify which sequential record belongs to what case?
 
S

Scuda

It's all in one table. When I open the form for input, the Case Number
automatically updates itself to the new one using:
DMax("[SENE_CASE_#]","tblSENESarLog")+1 in my default value, that works great.

All I really want is on another form that I have (kind of a Status Board if
you will) I have a box that says Coast Guard Sector SENE Next Case number
is: and then I want that number displayed in a text box.
 
K

K

So why not just create a query that displayes the information you want and
then create a form (Form1) as a data sheet that is based on the query and
then make another form (Form2) and put form one in it?

Scuda said:
It's all in one table. When I open the form for input, the Case Number
automatically updates itself to the new one using:
DMax("[SENE_CASE_#]","tblSENESarLog")+1 in my default value, that works great.

All I really want is on another form that I have (kind of a Status Board if
you will) I have a box that says Coast Guard Sector SENE Next Case number
is: and then I want that number displayed in a text box.



K said:
Even if the case number is not an auto number and as long as it it unique you
can still set it has primary and link to other tables. In the other tables
you will need to create a feild with the case number so you create a
relationship.

As far as I can see is that you need someway to link the case number to
other related records in order to do any programming or else how would the
program be able to idetify which sequential record belongs to what case?
 
S

Scuda

Well, all I really needed was to have a text box display a "next" number to
used on my status board. I am really not an access guru, I get by. I thought
it would be simpler to be honest with you !! lol

K said:
So why not just create a query that displayes the information you want and
then create a form (Form1) as a data sheet that is based on the query and
then make another form (Form2) and put form one in it?

Scuda said:
It's all in one table. When I open the form for input, the Case Number
automatically updates itself to the new one using:
DMax("[SENE_CASE_#]","tblSENESarLog")+1 in my default value, that works great.

All I really want is on another form that I have (kind of a Status Board if
you will) I have a box that says Coast Guard Sector SENE Next Case number
is: and then I want that number displayed in a text box.



K said:
Even if the case number is not an auto number and as long as it it unique you
can still set it has primary and link to other tables. In the other tables
you will need to create a feild with the case number so you create a
relationship.

As far as I can see is that you need someway to link the case number to
other related records in order to do any programming or else how would the
program be able to idetify which sequential record belongs to what case?

:

K, the case number is the seq number. It is not an autonumber but instead one
I created. It is a text box in my table.

Thanks.

:

Is the case number Linked (Relationship) between the sequential numbers that
apply? If so, you could just create a query that shows all the sequntial
records that pertain to each case number, then merge the query into a form
designed has a datasheet and insert into the form to be displayed

:

Sorry. It is a text box that is linked to a record in my table. It is a Case
number, that each record I create has it's own seq number.

Thanks!

:

What do you mean by "something" Is "My next number" a value or record?

:

Thanks Marshall, but I had an error with: Me.txtNext_ucn.Recalc when I
debugged.

I should also mention that my prev problem gave me a #error. Also, and I
don't think this matters btu the form I wanted to display this on, is not the
form where it is primarily used. That shouldn't matter as long as that same
table is my record source right?

Thanks again.
 
K

K

Lol, yeah I hear you. Sorry I sometimes do things the hardway but personally
I do not know of any other easier way? You can use the query wizard to
develop a query on the table and then just select the fields you want to
display in the query when building it in the wizard?... Hope I did not
confuse you too much and I helped in some way.



Scuda said:
Well, all I really needed was to have a text box display a "next" number to
used on my status board. I am really not an access guru, I get by. I thought
it would be simpler to be honest with you !! lol

K said:
So why not just create a query that displayes the information you want and
then create a form (Form1) as a data sheet that is based on the query and
then make another form (Form2) and put form one in it?

Scuda said:
It's all in one table. When I open the form for input, the Case Number
automatically updates itself to the new one using:
DMax("[SENE_CASE_#]","tblSENESarLog")+1 in my default value, that works great.

All I really want is on another form that I have (kind of a Status Board if
you will) I have a box that says Coast Guard Sector SENE Next Case number
is: and then I want that number displayed in a text box.



:

Even if the case number is not an auto number and as long as it it unique you
can still set it has primary and link to other tables. In the other tables
you will need to create a feild with the case number so you create a
relationship.

As far as I can see is that you need someway to link the case number to
other related records in order to do any programming or else how would the
program be able to idetify which sequential record belongs to what case?

:

K, the case number is the seq number. It is not an autonumber but instead one
I created. It is a text box in my table.

Thanks.

:

Is the case number Linked (Relationship) between the sequential numbers that
apply? If so, you could just create a query that shows all the sequntial
records that pertain to each case number, then merge the query into a form
designed has a datasheet and insert into the form to be displayed

:

Sorry. It is a text box that is linked to a record in my table. It is a Case
number, that each record I create has it's own seq number.

Thanks!

:

What do you mean by "something" Is "My next number" a value or record?

:

Thanks Marshall, but I had an error with: Me.txtNext_ucn.Recalc when I
debugged.

I should also mention that my prev problem gave me a #error. Also, and I
don't think this matters btu the form I wanted to display this on, is not the
form where it is primarily used. That shouldn't matter as long as that same
table is my record source right?

Thanks again.
 
S

Scuda

Nope, I certainly appreciate the help K.

K said:
Lol, yeah I hear you. Sorry I sometimes do things the hardway but personally
I do not know of any other easier way? You can use the query wizard to
develop a query on the table and then just select the fields you want to
display in the query when building it in the wizard?... Hope I did not
confuse you too much and I helped in some way.



Scuda said:
Well, all I really needed was to have a text box display a "next" number to
used on my status board. I am really not an access guru, I get by. I thought
it would be simpler to be honest with you !! lol

K said:
So why not just create a query that displayes the information you want and
then create a form (Form1) as a data sheet that is based on the query and
then make another form (Form2) and put form one in it?

:

It's all in one table. When I open the form for input, the Case Number
automatically updates itself to the new one using:
DMax("[SENE_CASE_#]","tblSENESarLog")+1 in my default value, that works great.

All I really want is on another form that I have (kind of a Status Board if
you will) I have a box that says Coast Guard Sector SENE Next Case number
is: and then I want that number displayed in a text box.



:

Even if the case number is not an auto number and as long as it it unique you
can still set it has primary and link to other tables. In the other tables
you will need to create a feild with the case number so you create a
relationship.

As far as I can see is that you need someway to link the case number to
other related records in order to do any programming or else how would the
program be able to idetify which sequential record belongs to what case?

:

K, the case number is the seq number. It is not an autonumber but instead one
I created. It is a text box in my table.

Thanks.

:

Is the case number Linked (Relationship) between the sequential numbers that
apply? If so, you could just create a query that shows all the sequntial
records that pertain to each case number, then merge the query into a form
designed has a datasheet and insert into the form to be displayed

:

Sorry. It is a text box that is linked to a record in my table. It is a Case
number, that each record I create has it's own seq number.

Thanks!

:

What do you mean by "something" Is "My next number" a value or record?

:

Thanks Marshall, but I had an error with: Me.txtNext_ucn.Recalc when I
debugged.

I should also mention that my prev problem gave me a #error. Also, and I
don't think this matters btu the form I wanted to display this on, is not the
form where it is primarily used. That shouldn't matter as long as that same
table is my record source right?

Thanks again.
 
S

Scuda

That did the trick!! Thanks Marshall!

Marshall Barton said:
That should do exactly what you said. What makes you think
"it did not work"?

There may be a confusing point about this kind of thing in
the DefaultValue property when you are creating a new record
with a new max value for the SENE_CASE_num field. Until the
new record has been saved, the max value in the table will
not be changed. Furthermore, the expression in a
DefaultValue property is not evaluated until the first
character is entered a control.

When you use that ecpression in a text box's ControlSource
property the text box's expression is not automatically
reevaluated (because it has no dependency on another
control). In this situation, you need to force it to
recalculated the value when the table is updated. You can
do this in the form's AfterUpdate event:
Me.thetextbox.Recalc
 
Top