If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Add New Record
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 |
#2
|
|||
|
|||
Add New Record
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 Alex Hammerstein wrote: 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 |
#3
|
|||
|
|||
Add New Record
Darrell's suggestion will work, but ***only*** if you want to do nothing but
add a new record. Data Entry set to Yes does not allow you to view/edit existing records, only to add new records. In order to do what you want ***and*** to view existing records, 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.com http://www.accessmonster.com/Uwe/For...forms/201002/1 |
#4
|
|||
|
|||
Add New Record
Thanks Both, Linq's response worked a treat
On 08/02/2010 17:39, in article a355fdf22e21f@uwe, "Linq Adams via AccessMonster.com" u28780@uwe wrote: Darrell's suggestion will work, but ***only*** if you want to do nothing but add a new record. Data Entry set to Yes does not allow you to view/edit existing records, only to add new records. In order to do what you want ***and*** to view existing records, use this code Private Sub Form_Load() DoCmd.GoToRecord , , acNewRec FirstFieldName.SetFocus End Sub |
#5
|
|||
|
|||
Add New Record
On Feb 8, 9:39*am, "Linq Adams via AccessMonster.com" u28780@uwe
wrote: 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 |
Thread Tools | |
Display Modes | |
|
|