Stop at last record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form that uses navigation buttons for the user to view all the
records. When they reach the last record and select next a blank record
appears. As I have some calculations that occur when the form loads this
results in the auto-number generating a new record in the table. If the user
didn't want to create a new record and leave the form I am left with a
redundant record in the table.

I have another button which utilises carry over code for new records so I
want the user to only use that for new records.

How do I force at "stop" at the last record?
 
New TO Access said:
I have a form that uses navigation buttons for the user to view all
the records. When they reach the last record and select next a blank
record appears. As I have some calculations that occur when the form
loads this results in the auto-number generating a new record in the
table. If the user didn't want to create a new record and leave the
form I am left with a redundant record in the table.

I have another button which utilises carry over code for new records
so I want the user to only use that for new records.

How do I force at "stop" at the last record?

If you set the form's AllowAdditions property to No, the user won't be
able to navigate to a new record. If your navigation buttons are not
the builtin ones, you may have to modify the code behind the "next
record" button to trap and ignore an error that may be raised when the
code tries to go to the next record. Naturallky, since I can't see the
code, I can't tell you exactly what changes you may have to make. An
alternative is to have code in the form's Current event to disable or
enable the "next record" button depending on whether you are on the last
record or not.

Your "new record" button may need to temporarily set the AllowAdditions
property to Yes before you go to the new record, in which case you'll
need code in some event -- maybe the form's AfterInsert event -- to set
it back to No again.
 
How do I force at "stop" at the last record?

Set the Form's AllowAdditions property to No. If you want to add
records, you can change this property when needed, or add the record
to the table in code.

John W. Vinson[MVP]
 
Back
Top