Open form and go to add new record

F

FSHOTT

Can someone tell/show me how I can go to adding a new record upon opening a
form. Currently the form design I have opens at the first record and users
inadvertanly incorrectly modify the fields to what they believe is a new
record. I need to fix it so they cannot do this. Thanks.....
 
D

Dirk Goldgar

FSHOTT said:
Can someone tell/show me how I can go to adding a new record upon opening
a
form. Currently the form design I have opens at the first record and users
inadvertanly incorrectly modify the fields to what they believe is a new
record. I need to fix it so they cannot do this. Thanks.....


There are several ways to go about this, depending on how you want the
application to work:

1. If you want the form always to open to a new record, and not let users
see existing records, you can set this in the design of the form by setting
its Data Entry property to Yes. That property is on the Data tab of the
form's property sheet in design view.

2. If you want the form to open to a new record when you open it from some
locations, but not from other locations, you can specify that in the code or
macro that opens the form, by specifying the appropriate value for the
optional DataMode argument. The VBA code would be along these lines:

DoCmd.OpenForm "YourFormName", DataMode:=acFormAdd

If you use a macro instead of code, the corresponding macro language should
be evident as you build or edit the macro.

3. If you want to open the form so that it shows all records, but is
positioned to a new record, you can do it with VBA code like this:

DoCmd.OpenForm "YourFormName"
Forms!YourFormName.Recordset.AddNew
 
K

KARL DEWEY

One way is to set the Data Entry property to Yes and all you can do is add
records, no viewing or editing.
 
F

FSHOTT

Dirk and Karl Thank You very much for the you instruction. I will give both
methods a try and see which works best for the users.
 
B

Bill

Dirk Goldgar said:
There are several ways to go about this, depending on how you want the
application to work:

1. If you want the form always to open to a new record, and not let users
see existing records, you can set this in the design of the form by
setting its Data Entry property to Yes. That property is on the Data tab
of the form's property sheet in design view.

2. If you want the form to open to a new record when you open it from some
locations, but not from other locations, you can specify that in the code
or macro that opens the form, by specifying the appropriate value for the
optional DataMode argument. The VBA code would be along these lines:

DoCmd.OpenForm "YourFormName", DataMode:=acFormAdd

If you use a macro instead of code, the corresponding macro language
should be evident as you build or edit the macro.

3. If you want to open the form so that it shows all records, but is
positioned to a new record, you can do it with VBA code like this:

DoCmd.OpenForm "YourFormName"
Forms!YourFormName.Recordset.AddNew


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


Number 3 worked great for me Dirk thanks :)

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top