Results 1 to 3 of 3
  1. #1
    shadowsedge is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2016
    Posts
    19

    prevent creating records until a button is clicked


    In Access 2016, is there a way to prevent a from from creating a record until a button is pressed?As of now, when 1 character is inserted, a new record is created. I would like that to happen only if a button is pressed on the bottom footer.I know this is the default action of access 2016. Is there an option to change it?

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    I believe that is pretty much the default behavior of Bound Forms in all versions of Access.

    You could always make it an unbound form, and then have your button write the record to the table by creating SQL code from the selections and running an Append (Insert) Query to add the record.

    Or you could get a little tricky and try using a Bound Form, and have some required field that is not listed on the Form, but gets filled out when the button is clicked. If you go that route, you might also need to add some error handling to handle different situations/scenarios (where they exit without clicking the button, it may give you some warnings about not being able to add the record).

  3. #3
    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
    With Unbound Forms you end up writing code for virtually everything that needs to be done, basically having Access do nothing; not an easy task for a programming newbie!

    I'd simply confirm, before the Record is actually saved, that the user wants to save it. Code to do this would be something like this:

    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    If Not (Me.NewRecord) Then
      If MsgBox("Would You Like To Save The Changes To This Record?", vbQuestion + vbYesNo + vbDefaultButton1, "Save Changes to Record ???") = vbNo Then
       Me.Undo
      End If
    Else
      If MsgBox("Would You Like To Save This New Record?", vbQuestion + vbYesNo + vbDefaultButton1, "Save This New Record ???") = vbNo Then
       Me.Undo
      End If
    End If
    End Sub

    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. Replies: 2
    Last Post: 03-16-2016, 09:21 AM
  2. Replies: 7
    Last Post: 08-18-2015, 08:05 AM
  3. Saving a Record Edit ONLY if button is clicked?
    By McArthurGDM in forum Forms
    Replies: 3
    Last Post: 06-01-2015, 09:33 PM
  4. Replies: 8
    Last Post: 11-21-2014, 04:39 PM
  5. disabling an enabled button that has been clicked.
    By aaron47 in forum Programming
    Replies: 3
    Last Post: 08-26-2011, 09:49 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