Save when editing a record

C

CharlesD

Hi,

I have a form that is attached to a table. I have set the following to:
Me.AllowAdditions = False
Me.AllowEdits = False
Me.AllowDeletions = False
I have an Edit command button that contains:
With Me
.AllowEdits = True
.LASTNAME.SetFocus
End With
I would like to have a Save button that updates or saves the record. I have
tried a DoCmd.RunCommand acCmdSave.
I get an error message that I need to be in an Edit or New state.
Understanding that the form is tied to a table and not a query, I do not know
how to update and put into an allowedit state to be False after clicking Save
button.
Moving off the record saves as required, but I would like to have the
cmdSave button do the same thing.

Regards,

Charles
 
G

George Atkins

Charles,
How about this:


Private Sub CmdEdit_Click()
Me.AllowEdits = True
End With
End Sub

Private Sub cmdSave_Click()
DoCmd.RunCommand acCmdSave
Me.AllowEdits = False
End With
End Sub

George
 
C

CharlesD

Hi George,

Worked great.

Thanks,

Charles

George Atkins said:
Charles,
How about this:


Private Sub CmdEdit_Click()
Me.AllowEdits = True
End With
End Sub

Private Sub cmdSave_Click()
DoCmd.RunCommand acCmdSave
Me.AllowEdits = False
End With
End Sub

George
 

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

Similar Threads

Allow Edits to Subform 2
Access Automatically Send a notification email once a record is added 0
Mandatory Fields 4
delete code, subform 1
error 2499 9
Help with allowedits 3
Cannot edit subform 3
Lock a record on Open 10

Top