Item incrementing

  • Thread starter Thread starter Scott
  • Start date Start date
S

Scott

1. How do I make a Form look at a Table, determine the
maximum value from an item, increment it by one when a
new record is created, and delete it when escape or
cancel is pressed (without autonumber)(The numbers Must
increment by one)? I cheated and wrote a little code to
go to the last record, save the number, create a new
record, and index the number by one. The problem with
this is that sometimes (Unknown why) the tables loses
index and my form doesn't see the "last" record.

2. Why do I have to repair the database sometimes to
make forms recognize all records and not lose index?

I looked at The Access Web and was unable to find what I
was looking for. Any help would be greatly appreciated.

Thank,

Scott
 
Scott,
Make the Default value for your numeric counter field.... (use your
name/s)
=DMax("[YourNumField]","tblYourTable") +1
When a new record is created, the next numeric value is automatically
entered. As long as you don't update the record, that field can be undone
by using ESC.
 
I don't know what would be causing #2. If the database is running across a network, it
could be a bad network connection.

For #1, set the Default Value of the control to

=DMax("[FieldName]", "TableName")+1

You shouldn't need to press Esc to get rid of this, since a DefaultValue won't make the
record dirty. The record won't be dirty unless a user also starts typing into it
somewhere, at which point pressing Esc will cancel.
 
Back
Top