Automatic increment

  • Thread starter Thread starter an
  • Start date Start date
A

an

Hello!

I have a Form with Textbox where I have record number.
When I add a new record, I would like to increment 1 on
last record number in Textbox but I don't know how?
Thanks in advance.
an
 
Assuming that you have a table where the Record Number is stored, you can
use the DMax function to do this. Use an expression similar to this in some
event to set the value of the next record number into the textbox:

Me.TextBoxName.Value = Nz(DMax("Record Number Field", "TableName"), 0) + 1
 
Thanks for your replay and sorry for my delay.

I whrited your code in command butom to Add New Record,
in [Event Procedure] On click, but Textbox to new record
number, return blank space. I don't know why.
an
 
Post the code that you've tried, and the code that you have so far.

--
Ken Snell
<MS ACCESS MVP>

an said:
Thanks for your replay and sorry for my delay.

I whrited your code in command butom to Add New Record,
in [Event Procedure] On click, but Textbox to new record
number, return blank space. I don't know why.
an

-----Original Message-----
Your reply post isn't complete?


--
Ken Snell
<MS ACCESS MVP>




.
 
Ok, Sorry.

T_Ills, field IdIll with PimaryKey/AutoNumber.
T_Consults with IdIll/Number to PrimaryKey of T_Ills.
One ill to many Consultations, on Relationships.
On MainForm with Ills.
On SubForm with Consultations.
In SubForm I need Add record/s with indication in Textbox
of consultation number by each ill (MainForm)

In Textbox of SubForm, I put your code:

Me.Text9.Value = Nz(DMax"IdConsult", "T_Consults"), Text9)
+ 1
Where Text9 is the total of Consultations, bu don´t work
for me.(?)

(If I put the code in OnClick [EventProcedure] of
CommandButton in SubForm, to add new record and certainly
incremente the number. It work but not only about the each
ill record select in MainForm.)

I know, is Very confuse... For me :-)
Sorry.
an

-----Original Message-----
Post the code that you've tried, and the code that you have so far.

--
Ken Snell
<MS ACCESS MVP>

Thanks for your replay and sorry for my delay.

I whrited your code in command butom to Add New Record,
in [Event Procedure] On click, but Textbox to new record
number, return blank space. I don't know why.
an

-----Original Message-----
Your reply post isn't complete?


--
Ken Snell
<MS ACCESS MVP>

Thanks for your replay, Ken
I don't know, but the Textbox to change to blank
an

-----Original Message-----
Assuming that you have a table where the Record
Number
is
stored, you can
use the DMax function to do this. Use an expression
similar to this in some
event to set the value of the next record number
into
the
textbox:

Me.TextBoxName.Value = Nz(DMax("Record Number
Field", "TableName"), 0) + 1


--
Ken Snell
<MS ACCESS MVP>

message
Hello!

I have a Form with Textbox where I have record number.
When I add a new record, I would like to
increment 1
on
last record number in Textbox but I don't know how?
Thanks in advance.
an



.



.


.
 
You're missing a parenthesis:

Me.Text9.Value = Nz(DMax("IdConsult", "T_Consults"), Text9) + 1

Are you sure you want to use Text9 as the default value if the DMax function
returns a Null? I recommend a zero instead.

--
Ken Snell
<MS ACCESS MVP>

Ok, Sorry.

T_Ills, field IdIll with PimaryKey/AutoNumber.
T_Consults with IdIll/Number to PrimaryKey of T_Ills.
One ill to many Consultations, on Relationships.
On MainForm with Ills.
On SubForm with Consultations.
In SubForm I need Add record/s with indication in Textbox
of consultation number by each ill (MainForm)

In Textbox of SubForm, I put your code:

Me.Text9.Value = Nz(DMax"IdConsult", "T_Consults"), Text9)
+ 1
Where Text9 is the total of Consultations, bu don´t work
for me.(?)

(If I put the code in OnClick [EventProcedure] of
CommandButton in SubForm, to add new record and certainly
incremente the number. It work but not only about the each
ill record select in MainForm.)

I know, is Very confuse... For me :-)
Sorry.
an

-----Original Message-----
Post the code that you've tried, and the code that you have so far.

--
Ken Snell
<MS ACCESS MVP>

Thanks for your replay and sorry for my delay.

I whrited your code in command butom to Add New Record,
in [Event Procedure] On click, but Textbox to new record
number, return blank space. I don't know why.
an

-----Original Message-----
Your reply post isn't complete?


--
Ken Snell
<MS ACCESS MVP>

Thanks for your replay, Ken
I don't know, but the Textbox to change to blank
an

-----Original Message-----
Assuming that you have a table where the Record
Number
is
stored, you can
use the DMax function to do this. Use an expression
similar to this in some
event to set the value of the next record number
into
the
textbox:

Me.TextBoxName.Value = Nz(DMax("Record Number
Field", "TableName"), 0) + 1


--
Ken Snell
<MS ACCESS MVP>

message
Hello!

I have a Form with Textbox where I have record number.
When I add a new record, I would like to
increment 1
on
last record number in Textbox but I don't know how?
Thanks in advance.
an



.



.


.
 
Ok, Ken

Grateful.
an
-----Original Message-----
You're missing a parenthesis:

Me.Text9.Value = Nz(DMax("IdConsult", "T_Consults"), Text9) + 1

Are you sure you want to use Text9 as the default value if the DMax function
returns a Null? I recommend a zero instead.

--
Ken Snell
<MS ACCESS MVP>

Ok, Sorry.

T_Ills, field IdIll with PimaryKey/AutoNumber.
T_Consults with IdIll/Number to PrimaryKey of T_Ills.
One ill to many Consultations, on Relationships.
On MainForm with Ills.
On SubForm with Consultations.
In SubForm I need Add record/s with indication in Textbox
of consultation number by each ill (MainForm)

In Textbox of SubForm, I put your code:

Me.Text9.Value = Nz(DMax"IdConsult", "T_Consults"), Text9)
+ 1
Where Text9 is the total of Consultations, bu don´t work
for me.(?)

(If I put the code in OnClick [EventProcedure] of
CommandButton in SubForm, to add new record and certainly
incremente the number. It work but not only about the each
ill record select in MainForm.)

I know, is Very confuse... For me :-)
Sorry.
an

-----Original Message-----
Post the code that you've tried, and the code that you have so far.

--
Ken Snell
<MS ACCESS MVP>

Thanks for your replay and sorry for my delay.

I whrited your code in command butom to Add New Record,
in [Event Procedure] On click, but Textbox to new record
number, return blank space. I don't know why.
an


-----Original Message-----
Your reply post isn't complete?


--
Ken Snell
<MS ACCESS MVP>

message
Thanks for your replay, Ken
I don't know, but the Textbox to change to blank
an

-----Original Message-----
Assuming that you have a table where the Record Number
is
stored, you can
use the DMax function to do this. Use an expression
similar to this in some
event to set the value of the next record number into
the
textbox:

Me.TextBoxName.Value = Nz(DMax("Record Number
Field", "TableName"), 0) + 1


--
Ken Snell
<MS ACCESS MVP>

message
Hello!

I have a Form with Textbox where I have record
number.
When I add a new record, I would like to increment 1
on
last record number in Textbox but I don't know how?
Thanks in advance.
an



.



.


.


.
 
Back
Top