text box on form

G

Guest

I have a table that has a number for each record. I also have a form that
people add the records to. I have a text box on this form that i would like
it to show the next number in the list. for example if the last number in the
table is 200, I would like to text box on the form to show 201, and when they
select the button to add the record i would like it to then show hte next
record 202. I hope this makes sense. Any information would be great. Thanks.
 
F

fredg

I have a table that has a number for each record. I also have a form that
people add the records to. I have a text box on this form that i would like
it to show the next number in the list. for example if the last number in the
table is 200, I would like to text box on the form to show 201, and when they
select the button to add the record i would like it to then show hte next
record 202. I hope this makes sense. Any information would be great. Thanks.

As the default value property of the RecordNumber control on the form,
write:
DMax("[RecordNumber]","TableName") + 1
 
M

Marshall Barton

Erik said:
I have a table that has a number for each record. I also have a form that
people add the records to. I have a text box on this form that i would like
it to show the next number in the list. for example if the last number in the
table is 200, I would like to text box on the form to show 201, and when they
select the button to add the record i would like it to then show hte next
record 202.


I think(?) you want code like:

Me.textbox.DefaultValue = Nz(DMax("numberfield", _
"thetable"), 0) + 1

in both the form's Load and AfterUpdate events.

It it important to avoid setting the text box's Value just
for a visual effect bucause that would dirty the record and
cause it to be saved even if you don't enter any data.

If you do not really need to see the number, then you can
set the value in the form's BeforeUpdate event:

Me.textbox= Nz(DMax("numberfield", "thetable"), 0) + 1
 

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