Save when editing a record

  • Thread starter Thread starter CharlesD
  • Start date Start date
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
 
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
 
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
 
Back
Top