Hi,
I have a form with a button for add new record that works fine. I added a
second button to save the current record.
I need two things:
1- after user fills all the fields in the form I do not want to move to the
next new reord.
2- Add a save button so that the record is saved.
I tried the follwing code for saving the record but it does not work:
Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click
Dim stDocName As String
stDocName = "frmTagEmployeeSample"
DoCmd.Save stDocName
Exit_cmdSave_Click:
Exit Sub
Err_cmdSave_Click:
MsgBox Err.Description
Resume Exit_cmdSave_Click
End Sub
Can any one help with the code?
Khalil
Allen Browne - 30 Jul 2005 11:53 GMT
Try:
If Me.Dirty Then Me.Dirty = False
or if you prefer:
RunCommand acCmdSaveRecord

Signature
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
> I have a form with a button for add new record that works fine. I added a
> second button to save the current record.
[quoted text clipped - 24 lines]
> Can any one help with the code?
> Khalil
Jörg Ackermann - 30 Jul 2005 11:53 GMT
Hi,
Khalil schreibselte:
> Hi,
> I have a form with a button for add new record that works fine. I
> added a second button to save the current record.
> I need two things:
> 1- after user fills all the fields in the form I do not want to move
> to the next new reord.
Set the Cycle-Property of the form to 'actual Record'
> 2- Add a save button so that the record is saved.
Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click
Me.Dirty = False
Exit_cmdSave_Click:
Exit Sub
Err_cmdSave_Click:
MsgBox Err.Description
Resume Exit_cmdSave_Click
End Sub
or
Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click
Docmd.RunCommand accmdSaveRecord
Exit_cmdSave_Click:
Exit Sub
Err_cmdSave_Click:
MsgBox Err.Description
Resume Exit_cmdSave_Click
End Sub
Acki
Khalil - 30 Jul 2005 12:02 GMT