Open Blank Form When Database is Opened, Access VBA
Previously in the article Open Form When Database is Opened, Access I’ve explained how you can cause a form to appear every time the an Access file is opened. By default the form will be displaying the first record in the table:
In this article I will explain how you can cause a blank form to appear rather than a form with data from the first record.
Contents
Step 1:
Open the form in design view:
Step 2:
Click on the View Code button on the Design ribbon:
The following window will open:
Step 3:
If no previous macros have been written you will only see one class in the project explorer on the left:
If there are multiple classes on the left click on the forms class. It will have a name in the format:
- Form_“FormName”
where “FormName” is the name of the form, which in our case is “Form1”.
Write the following code inside the Form_Form1 class:
Private Sub Form_Load()
Call DoCmd.GoToRecord(, , acNewRec)
End Sub
Result:
Whenever the Access file is opened, a blank form will appear ready to input a new record:
You can download the sample file and code used in this article from the link below:
See also:
- Open Form When Database is Opened, Access
- Access Create Popup Form
- Access Startup Form
- Guide to docmd.openform
If you need assistance with your code, or you are looking for a VBA programmer to hire feel free to contact me. Also please visit my website www.software-solutions-online.com