How do I restrict AllowAdditions and DataEntry to just a single record at a time

D

Douglas

I have a form which allows two modes

1. Browsing records (Show All)
2. Adding new records (Add New)

I have a button called "Add New" which sets

Form.AllowAdditions = True
Form.DataEntry = True

and a button called Show All which sets

Form.AllowAdditions = False
Form.DataEntry = False

this works fine but currently the user, when in Add New mode, can add
in multiple new records by using the navigations buttons but I would
like to restict the Add New mode to just 1 record. This means they
would click the "Add New" button, enter the data for one new record,
then click a Save button and it would jump back to "Show All" mode at
the record they just entered.

So my question is how do i restrict "Add new" to only allow 1 record
per "Add New".


Hope this makes sense


TIA
Doug
 
T

Tony C

There is a better way of doing this: -

1. Delete all of the current code that you have.
2. On the Forms "On Current" Procedure, set the property
Me.AllowAdditions=False
3. Create a new Button "Add Record". For this
button's "On Click2 Procedure, add the following code: -
Me.AllowAdditions=True
docmd.GoToRecord,,acNewRec
Me.Field1.SetFocus

Note that I've added the line Me.Field1.SetFocus to set
the focus to the first field that is to be edited, change
the text "Field1" accordingly.

HTH

Tony C
 
N

Nick Coe

Doug,

When your Add New button is clicked I suggest you also
turn off the navigation buttons at the bottom of your form.

Me.NavigationButtons = False

Unless you want to see lock status you could turn off
record selectors aswell, just one less thing for the user
to click madly at 'trying to make it do something' :).

By the way... Is this form set as a single form? Needs to
be so rather than continuous forms.

You may have an issue with users going into the menus and
changing things but best deal with that seperately.

Good luck

Nick Coe
Lincoln UK
classicnick at yahoo dot com
 
N

Nikos Yannacopoulos

Brilliant!

Tony C said:
There is a better way of doing this: -

1. Delete all of the current code that you have.
2. On the Forms "On Current" Procedure, set the property
Me.AllowAdditions=False
3. Create a new Button "Add Record". For this
button's "On Click2 Procedure, add the following code: -
Me.AllowAdditions=True
docmd.GoToRecord,,acNewRec
Me.Field1.SetFocus

Note that I've added the line Me.Field1.SetFocus to set
the focus to the first field that is to be edited, change
the text "Field1" accordingly.

HTH

Tony C
 
N

Nikos Yannacopoulos

Nick,

This is a step in the right direction, but it doesn't prevent users from
scrolling to the next record with the mouse wheel. Actually I would combine
both your and Tony's suggestions.

Nikos
 

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