How to open Form in Add record

2019-04-19 18:42发布

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.

3条回答
聊天终结者
2楼-- · 2019-04-19 18:47

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
查看更多
We Are One
3楼-- · 2019-04-19 18:53

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

查看更多
对你真心纯属浪费
4楼-- · 2019-04-19 19:06

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).

查看更多
登录 后发表回答