logo
search
Others

How to Add an Access Button to Create a New Record

Rana GarciaRana Garcia Sep 28, 2026 869 views

Question details

The user needs to add a command button to a Microsoft Access form that safely creates a new blank record without executing if the form is already on a new record.

How to Add a Command Button to Create a New Record in Access
Product
Microsoft Access
Device & OS
not provided
Scenario
Designing a database form and wanting to provide users with a clickable interface button to easily add new entries.
Observed behavior
A functioning command button that triggers a new record creation using VBA, safely evaluating the current form status to avoid duplicating commands.
Before you start

Ensure your Microsoft Access database is open in Design View and that you have basic familiarity with the VBA (Visual Basic for Applications) editor.

Solution 1Recommended

Use VBA in the Click Event of a Command Button

Create a command button and assign a VBA script to its Click event to evaluate the current record state before adding a new one.

Using VBA provides precise control over form behaviors. By checking the form's NewRecord property first, you prevent Access from attempting to append a new row when the user is already positioned on a blank record, which avoids unnecessary errors.

1
Open the Form in Design View

Right-click your form in the Access navigation pane and select 'Design View' to begin editing the form layout.

2
Add a Command Button

Navigate to the Form Design tab on the ribbon, click the 'Button' control, and click anywhere on your form to place it. If the Command Button Wizard automatically opens, click 'Cancel' to close it.

3
Name the Command Button

Select the newly created button, press F4 to open the Property Sheet, navigate to the 'Other' tab, and type 'cmdYourNewAddButton' into the Name property.

4
Access the Click Event

Switch to the 'Event' tab within the Property Sheet, locate the 'On Click' property, click the ellipsis (...) button next to it, and select 'Code Builder'.

5
Insert the VBA Code

In the VBA editor that opens, paste the following code between the Private Sub and End Sub lines: 'If Not Me.NewRecord Then Me.Recordset.AddNew End If'. Save and close the VBA editor.

Use VBA in the Click Event of a Command Button
Production Tip: For robust production databases, consider wrapping your VBA code with standard error-handling routines (such as On Error GoTo) to gracefully manage unexpected validation rule violations or database locks.
Free Microsoft Office alternative

Need a Powerful, Free Alternative to Microsoft Office?

While WPS Office does not include a database management tool like Access, it serves as a highly compatible and lightweight alternative for Word, Excel, and PowerPoint. If you are looking to save on licensing costs for your daily document processing, WPS Office is an excellent choice.

  1. 1. Download the Installer: Visit the official WPS Office website and click the Free Download button.
  2. 2. Install WPS Office: Run the downloaded installer file and follow the straightforward on-screen instructions.
  3. 3. Start Creating Documents: Open WPS Office to instantly begin creating or editing your spreadsheets, documents, and presentations.
Fully compatible with Microsoft Word, Excel, and PowerPoint formats (.docx, .xlsx, .pptx).Lightweight design that runs smoothly on Windows, Mac, and Linux environments.Familiar, tabbed user interface requiring zero learning curve for rapid migration.Built-in PDF editing and conversion capabilities at no extra cost.
microsoft office alternative - wps office

Frequently Asked Questions

Can I use macros instead of VBA to create a new record?

Yes. You can use the Command Button Wizard to automatically assign a macro that navigates to a new record. However, writing a custom VBA script offers more precise control, such as utilizing the Me.NewRecord check to prevent execution errors if the form is already displaying a blank entry.

What happens if I try to add a new record when I am already on one?

Without the 'If Not Me.NewRecord Then' validation check, Access might trigger a run-time error or unnecessarily refresh the blank state, which could disrupt the user's data entry workflow.

How do I ensure the current record is saved before clicking the new record button?

In Microsoft Access, navigating away from the current record to a new one automatically triggers a save action for the previous record's data, provided it passes all defined validation rules. Explicit save code is usually not required before executing Me.Recordset.AddNew.