How to hide the new record fields in a form except when I want to add a new record

There is always a blank new record at the bottom of a continuos form waiting for new data to be enetered.  This can be not shown by saying no to allow additions in the properties box.

How can I switch between allow additions and not allow additions so that in normal viewing the blank fields are not seen but when a button is clicked to add a new record then the form is switched to allow aditions
LVL 1
jimcrintAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arif_eqbalCommented:
What are you using DBGrid??
SajjaninjCommented:
too much little info.. what are the controls,dao or ADO... etc.
jimcrintAuthor Commented:
Sorry I was not thinking that other people would be able to read my mind

I am using Access 2000.  I have created forms and normally have a button to add a new record then take control to the first field.

This client does not want to see the empty new record so I thought I could turn on and off the "allow additions" that is available in the properties,

This may be to simplistic and I need to create the new record in the table then refresh the form to show it.  Not quite sure here.
jmacmickingCommented:
Set the form's AllowAdditions (under the Data tab) property to false.  This will turn off the blank record at the end of the list.

In the code for the button put the lines
  Me.AllowAdditions = True
  DoCmd.GoToRecord , , acNewRec

This will turn additions back on and move the highlight to the new record.  However, once they start typing the form will create another empty record.  There are two ways to avoid this (that I can think of)--one is to change one or more of the values on the new record in code right after it's created then set Me.AllowAdditions back to False.  Since the new record is dirty it won't disappear when AllowAdditions is turned off.  The other method is to set the OnChange event of each control to turn off AllowAdditions if it's on.  Personally, I'd just set one of the values to a default with this code (put it in the button's Click event):

  Me.AllowAdditions = True
  DoCmd.GoToRecord , , acNewRec
  Me.RowName = ""
  Me.AllowAdditions = False

Two other options that may work, even if they aren't quite what you asked for:
    Don't allow additions on the list form at all; when the button is clicked open a seperate form designed for data entry (set it's DataEntry property to true so it only shows new records).  On the close event of the new form force the continous form to requery (to capture the new data).
    Put all the controls necessary for a new record in the form footer, put a "Add Record" and "Cancel" button as well.  Mark them all as Visible=False initially.  When the Add button is clicked show the controls.  If the person clicks Add Record add the record programatically and then requery the form.  If they click Cancel just set all the controls back to default values (blank, probably) and set thier visible property back to False.

Personally, I'm a fan of seperate forms for data entry.  It's much easier to validate the data and it's often clearer to fill out.  If you need more detail on any of these methods or have any questions let me know.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jimcrintAuthor Commented:
Excellent, just what i wanted

I had already done one of your other options for a separate form to input data into but there are about 6 of these in sub forms and tabs so it would be come rather messy for me.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.