Add New Record

  • Thread starter Thread starter Alex Hammerstein
  • Start date Start date
A

Alex Hammerstein

Hi

When opening a form, I want to add a new record and set focus in the first
field.

Can someone tell me the code please - I cant seem to find it
Thanks
 
Go into the Design view of the form and in the form's properties set
Data Entry to Yes. This will make the form open up in Data Entry mode,
ready to add a new record.

To set focus in the first field, while in Design view, click on View
(menu), Tab Order, then set the order for how you'd like the user to tab
through the fields on the form.
Darrell
 
Darrell's suggestion will work, but ***only*** if you want to do nothing butaddanewrecord. Data Entry set to Yes does not allow you to view/edit
existingrecords, only toaddnewrecords.

In order to do what you want ***and*** to view existingrecords, use this
code

Private Sub Form_Load()
  DoCmd.GoToRecord , , acNewRec
  FirstFieldName.SetFocus
End Sub

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/access-forms/201002/1

I tested the code. It seems that the code above can update record,
but can not add new record.

I created a form for training records. The data source is table
TRAINING. The form has Combo box that is used to select employee. When
the employee is selected, the employee's data, such as employee_id,
manager, phone, training_course display in the form. This part of the
form works well. There is new request from my clint. It's requsted
that when the training_course displayed on the form is changed,
the record with new training_course can be added into table TRAINING.
So, I created "Add" buttorn on the form and used append query method
to add the records into the TRAINING table. However, it did
not work as I expected. Using append query method, All records of the
emplyee in the TRAINING were added into the table, which is not I
wanted. I just want to add the new record of the employee (the record
shown on
the form) to be added into the table. I am not expert on Access. I
tested the code above on my form, it can update the record, but can
not added the record as new record.

I appreciate any of the help on my issue.

Thanks

Frank
 
Back
Top