Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open Form in Add record

I have a form to input records to a table. I would like it to open on an empty add (New) instead of displaying the first record of the table. To be used by a Navigation Form which opens the input form from a button.

like image 286
Tom Gross Avatar asked Feb 23 '12 17:02

Tom Gross


People also ask

How do I add a record to a form in Access?

Add a record to a table or form. Open the table in Datasheet View or the form in Form View. On the Home tab, in the Records group, click New, or click New (blank) record, or press Ctrl+Plus Sign (+).

How do I open a form in Microsoft Access?

Click Current Database. Under Application Options, in the Display Form list, select the form that you want to display when the database starts. Click OK, and then close and reopen the database to display the startup form.

How do I add a form to a database?

To create a form from a table or query in your database, in the Navigation Pane, click the table or query that contains the data for your form, and on the Create tab, click Form. Access creates a form and displays it in Layout view.


3 Answers

You can use acFormAdd (value = 0) as the optional DataMode argument to OpenForm. Access' help describes acFormAdd as "The user can add new records but can't edit existing records." And actually, not only does that prevent editing of existing records, they are not even displayed in the form with that option.

DoCmd.OpenForm "frmaw_save",,,,acFormAdd

If you want to always use the form that way, you can set its Data Entry property to Yes (on the Data tab of the form's property sheet).

like image 139
HansUp Avatar answered Oct 19 '22 03:10

HansUp


In the Form_Load event use the GoToRecord Method of DoCmd and pass in acNewRec for the Offset.

Private Sub Form_Load()
   DoCmd.GoToRecord , , acNewRec
End Sub
like image 29
Conrad Frix Avatar answered Oct 19 '22 04:10

Conrad Frix


On the property sheet, set "Data Entry" to Yes. You can turn off navigation buttons too.

like image 32
RussWill Avatar answered Oct 19 '22 03:10

RussWill