Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code to Save a Record 1

Status
Not open for further replies.

zevw

MIS
Jul 3, 2001
697
US
When I have a form and enter a new record or change a record. I would like to make that the Enter Key (vbkeyReturn) should save the record.

Can anyone help me what is the code for saving a record without going to the next record.

The way I am saving records till now, is by going to the next record (Docmd.GoToRecord ,,acnext).

I want to stay in the same record and save it.
 
Not sure if you've tried this but here goes.

Private Sub Save_Record_Click()
On Error GoTo Err_Save_Record_Click

DoCmd.GoToRecord , , acNewRec

Exit_Save_Record_Click:
Exit Sub

Err_Save_Record_Click:
MsgBox Err.Description
Resume Exit_Save_Record_Click

End Sub
 
Code:
DoCmd.RunCommand acCmdSaveRecord
will save the changes without moving to the next record.

HTH,
Ami D. Shroyer, MCSD
AmiDenise@yahoo.com

 
Thanks!

I know about acNewRec and acNext or acPrevious they all save the record.

I want the code how to save record within the same record not moving to a different record.
 
Thanks Ami, that is what I needed simple but very helpful.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top