locked
Can I use a button on a form to save and go to new record at the same time when clicked? RRS feed

  • Question

  •  

    I wrote this peice of code:

    Private Sub CommandAddNew_Click()
    If Me.NewRecord Then
    DoCmd.RunCommand (acCmdSaveRecord)
    Else
    DoCmd.RunCommand (acCmdRecordsGoToNew)
    End If
    End Sub


    What I am really trying to do is use a single button to save the record and go to new record. Meaning when the user click the button, the record is saved and there is a new form to enter a new record.

    How can I do this?

     

    Thanks everyone!

    SYN

    Monday, October 3, 2011 3:48 PM

Answers

  • Perhaps, just

    Private Sub CommandAddNew_Click()
    DoCmd.RunCommand (acCmdSaveRecord)
    DoCmd.RunCommand (acCmdRecordsGoToNew)
    End Sub


    HTH, Bernie
    • Marked as answer by Synthologic Monday, October 3, 2011 4:38 PM
    Monday, October 3, 2011 4:21 PM

All replies

  • Perhaps, just

    Private Sub CommandAddNew_Click()
    DoCmd.RunCommand (acCmdSaveRecord)
    DoCmd.RunCommand (acCmdRecordsGoToNew)
    End Sub


    HTH, Bernie
    • Marked as answer by Synthologic Monday, October 3, 2011 4:38 PM
    Monday, October 3, 2011 4:21 PM
  • Perhaps, just

    Private Sub CommandAddNew_Click()
    DoCmd.RunCommand (acCmdSaveRecord)
    DoCmd.RunCommand (acCmdRecordsGoToNew)
    End Sub


    HTH, Bernie


    Thank you so much, works perfectly!

     

    SYN

    Monday, October 3, 2011 4:38 PM
  • Hey - you wrote the code: I was just guessing! ;-)
    HTH, Bernie
    Monday, October 3, 2011 5:41 PM