A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Add New Record



 
 
Thread Tools Display Modes
  #1  
Old February 8th, 2010, 03:51 PM posted to microsoft.public.access.forms
Alex Hammerstein
external usenet poster
 
Posts: 70
Default 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  
Old February 8th, 2010, 04:39 PM posted to microsoft.public.access.forms
Darrell Childress[_3_]
external usenet poster
 
Posts: 32
Default 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  
Old February 8th, 2010, 05:39 PM posted to microsoft.public.access.forms
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default 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  
Old February 8th, 2010, 06:33 PM posted to microsoft.public.access.forms
Alex Hammerstein
external usenet poster
 
Posts: 70
Default 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  
Old February 9th, 2010, 06:10 PM posted to microsoft.public.access.forms
Frank[_26_]
external usenet poster
 
Posts: 13
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:23 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.