Add New Record

Taff

Registered User.
Local time
Today, 13:09
Joined
Feb 3, 2004
Messages
158
Hopefully an easy one to answer.

I have a form with a command button on with an On_Click event of DoCmd.GoToRecord , , acNewRec.

What I would like to happen is when the user clicks this Add New Record command button it stays on this record until either the record is saved or it is cancelled.

Is this possible? :confused:

Thanks


Anthony
 
Taff said:
I have a form with a command button on with an On_Click event of DoCmd.GoToRecord , , acNewRec.

What I would like to happen is when the user clicks this Add New Record command button it stays on this record until either the record is saved or it is cancelled.

The second it moves to a new record the current record is saved. So, you'll have to do the checking manually.

i.e.

Code:
Private Sub MyButton_Click()
    If Me.Dirty Then
        If MsgBox("Save changes to this record?", vbQuestion + vbYesNo, "Save") = vbYes Then
            DoCmd.RunCommand acCmdSaveRecord
        Else
            Me.Undo
        End If
    End If
    DoCmd.GotoRecord, , acNewRec
End Sub
 
Exactly what I need.

Thanks Mile-O-Phile

Ant :)
 

Users who are viewing this thread

Back
Top Bottom