access form - next record question



How can I modify this code to NOT add a new record if I am at the end of the file?

DoCmd.GoToRecord , , acNext
LVL 1
geedub1961Asked:
Who is Participating?
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
"How can I modify this code to NOT add a new record if I am at the end of the file?"
That code does not 'add' a new record. It only puts you at the New Record position.

However ... IF, you have code in the Form Current event that sets any values in bound fields, then a new record *will be* created, possibly erroneously.  This is why it is not a good idea to set values in the Form Current event.

Are you getting erroneous records - and thus the reason for the Question?

mx
0
 
Rey Obrero (Capricorn1)Commented:
you can use

DoCmd.GoToRecord , , acPrevious

or

DoCmd.GoToRecord , , acFirst
0
 
Boyd (HiTechCoach) Trimmell, Microsoft Access MVPCommented:
The way I like to handle this is to set the form's property for Allow Additions to false.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Rey Obrero (Capricorn1)Commented:
the op might be using a user define record navigation
see this similar  thread

http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_20843155.html#a10062324
0
 
geedub1961Author Commented:
I want to do a calculation on each of the items in my data - on the last row I want to stop the process - however it keeps adding a new rows to the bottom of the dataset.



 
0
 
geedub1961Author Commented:
What I want to happen is this

Start on row1 - calculate depreciation - move to row2 same calc and repeat process until I get to the final row and then stop the process.

So far I can start on row1 and continue - but when I get to the end of the data it adds new rows to the data.

0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Post any code you have in the Form Current event.

mx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.