Results 1 to 5 of 5
  1. #1
    Teri.B is offline Novice
    Windows 10 Access 2019
    Join Date
    Oct 2023
    Posts
    2

    Save button

    Team, I have the following code that prompts the user to click the save button. The code appears to be working, but what I really want is for the form entry to save and open to a new entry. So once the save button is clicked the data is saved and a new record opens.

    Dim frmSave As Boolean




    Private Sub BtnSave_Click()
    frmSave = True
    If Me.Dirty Then Me.Dirty = False
    End Sub

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    If frmSave = False Then
    Cancel = True
    MsgBox "You must press the save button to save the record,"
    End If
    frmSave = False
    End Sub

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Please post multi-line code between CODE tags to retain indentation and readability.

    Docmd.GoToRecord , , acNewRec
    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
    Teri.B is offline Novice
    Windows 10 Access 2019
    Join Date
    Oct 2023
    Posts
    2
    Thank you!

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Moving to another record will automatically commit current record. Other code to save is not necessary, just move.
    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.

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

Similar Threads

  1. Replies: 15
    Last Post: 03-07-2023, 01:43 PM
  2. Replies: 2
    Last Post: 11-13-2017, 08:51 AM
  3. Replies: 3
    Last Post: 10-20-2014, 03:25 PM
  4. form - save entered data only with save button
    By cbrxxrider in forum Forms
    Replies: 3
    Last Post: 10-20-2013, 12:39 PM
  5. Replies: 3
    Last Post: 10-08-2012, 08:40 AM

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