Software

Replace Access navigation bars with a command button for easier data entry

When designing a data entry form, it's a good idea to replace the navigation bars with an Add New Record command button. A conveniently placed button not only makes it easier to enter data, but it also can help prevent existing records from inadvertent overwriting. Mary Ann Richardson shows how to create an Add New Record command button to your form.

When designing a data entry form in Access, it’s a good idea to replace the navigation bars with an Add New Record command button. A conveniently placed button not only makes it easier to enter data, but it also can help prevent existing records from inadvertent overwriting.

To create an Add New Record command button to your form, follow these steps:

  1. Click the Form Properties button.
  2. Click the Format tab.
  3. Click the Navigation Buttons property box and select No.
  4. Click the Toolbox button if necessary.
  5. Click the Command Button tool.
  6. Click and drag in your form where you want to position the Command Button.
  7. Under Categories, select Record Operations.
  8. Under Actions, select Add New Record.
  9. Click Next.
  10. Click the Text text box and change the display text to Add New Record.
  11. Click Next.
  12. Type cmdAddRecord for the control name.
  13. Click Finish.

Miss an Access tip?

Check out the Microsoft Access archive, and catch up on our most recent Access tips.

Help users increase productivity by automatically signing up for TechRepublic's free Microsoft Office Suite newsletter, featuring Word, Excel, and Access tips, delivered each Wednesday.

4 comments
chuckoliver.hrc
chuckoliver.hrc

Whenever creating an end-user application, control data integrity by following good programming practices. Yes, an add record button instead of allowing use of the nav bar is preferred however, don't forget to include error-trapping (I always test for null values in critical fields)before saving a record and then remember to recycle the data entry form (i.e. GoTo NewRecord and GoTo Control). An alternative is to use a macro in the button's OnClick property to RunCommand-Save, if no error, then GoToRecord-New then GoToControl-1st field on form. Now you've "walked" the user through data entry while maintaining control of record integrity!

Nancy.Hadaway
Nancy.Hadaway

I like the idea of the "add record" button and appreciate the heads up about error trapping. Thanks for the follow-up.

anthony
anthony

Hi this sounds really great is there an easy way to make all controls on the form read only until the add new button is pressed? or an update button is pressed?

ssharkins
ssharkins

To disable a control use the following syntax: Dim ctl As controltype Set ctl = Me!controlname ctl.Enabled = False To enable the control set the Enabled property to True. Another method, which is often easier is to toggle the property as follows: ctl.Enabled = Not (ctl.Enabled) Knowing where and when to reset the property is the key to success. Do you want the form to open with enabled controls? When you disable them, remember to enable them, accordingly -- but yes, it's relatively simple to do. You can even use a For Each loop to cycle through all the controls so you don't have to hardcode the controlnames, but be careful -- you want to omit labels and other non-data type controls from the disabling statement, so be sure to add a check for the control types you want to include (or exclude as the case may be). Try it out and get back to me if you have trouble implementing.