Results 1 to 4 of 4
  1. #1
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352

    A Better way to Save & Proceed to New Entry Form?

    I am looking for a better, surefire, way to save entered data and then proceed to new clean record for the user to enter new data into. Currently the coding behind my button is


    Code:
    Private Sub bttnSaveEntry_Click()
    DoCmd.Save
    DoCmd.GoToRecord , , acNewRec
    End Sub
    I realize the Save command is redundant in the case of go to a new record, however I added it in there as a safeguard since occasionally when the user clicks the button it will be presented with an error message "error "###" cannot proceed to designated record" or something similar. I used to have " , , acNext" but kept getting that message to switched it to NewRec. I haven't been able to figure out a better way to execute saving the record and proceeding to a clean form for entry. I have some fields set as required so I can't just set everything to null, plus it needs to save the data first. Thanks for help

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    IIRC Docmd.save is not saving any data and will throw an exception if used in an accde or on a machine that only has Runtime installed.

    I use

    If Me.Dirty then
    Me.dirty = false
    end if

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Right, the correct method would be:

    DoCmd.RunCommand acCmdSaveRecord

    OR the method shown by ItsMe.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    As ItsMe suggested, your attempt to save the Record

    DoCmd.Save

    doesn't save the data in a Record! It saves Design Changes made to the current object, when no object is specified; in this case it would be the Form itself.

    If you're receiving an error saying that you cannot go to the designated Record, you need to figure out the real reason why, because whether or not the Current Record has been saved has no bearing on moving to a New Record via the OnClick event of a Command Button.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Are you sure you want to proceed
    By mike02 in forum Programming
    Replies: 1
    Last Post: 06-04-2013, 07:49 AM
  2. Replies: 1
    Last Post: 04-21-2013, 06:13 PM
  3. Replies: 5
    Last Post: 02-05-2013, 10:57 PM
  4. Replies: 1
    Last Post: 01-15-2011, 02:47 AM
  5. Replies: 1
    Last Post: 05-30-2009, 04:00 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums