Stop 'next record' from adding from adding records

Y

Ynot

I have a sub-form with first-last-next- and new record buttons. How can I
stop someone from using the next button to get to the end of the records and
adding a new record? I have specific code that runs when the 'new' button
is pressed but it can be circumvented if they go to 'last record' and press
'next'?
 
S

Someone

Open the subform in design view and open its properties. Change 'Allow
Additions' to No.

M
 
M

Marshall Barton

Ynot said:
I have a sub-form with first-last-next- and new record buttons. How can I
stop someone from using the next button to get to the end of the records and
adding a new record? I have specific code that runs when the 'new' button
is pressed but it can be circumvented if they go to 'last record' and press
'next'?


Put your code in the form's Current event instead of behind
a separate button. This way, it won't matter how they get
to a new record.

If Me.NewRecord Then
' your code here
End If

Be careful about automatically setting values in a new
record. If the user makes a mistake and goes to a new
record accidently, they need to remember to hit the ESC key
twice before navigating to a different record.

This is a little odd. There was essentially the same
question ib anothre newsgroup a couple of hours ago, almost
as if this is a homework assignment.
 
Y

Ynot

Won't that stop all additions? I want to allow a new record if they select
the 'new' button but simply stop them on the 'next' button.
 
S

Someone

Hi Ynot

Yes, that's right, but you can add code to your 'New' button that allows you
to add new records programatically.

Me.Allowadditions = True

Or, if on Subform:

Parent.Subform.Form.AllowAdditions = True

Thanks
M
 
Y

Ynot

Ah... That will works..... THANX!

Someone said:
Hi Ynot

Yes, that's right, but you can add code to your 'New' button that allows
you to add new records programatically.

Me.Allowadditions = True

Or, if on Subform:

Parent.Subform.Form.AllowAdditions = True

Thanks
M
 
S

Someone

You're welcome. Don't forget to set it to False afterwards.

You can also create manual buttons as well - this way, you won't have the
Add button.

M
 

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