Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8793773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:09:57+00:00 2026-06-13T23:09:57+00:00

I’ve been working in Access on a project and the longer I work on

  • 0

I’ve been working in Access on a project and the longer I work on it the more disdain I have for it. I’ve been googling and attempting workarounds all day but I can’t quite find what I am trying to do.

I have a form that is linked to a table. I have one button that will set the record of the form to a new record. If you start typing into any one of the text boxes the record starts updating, it’s not really doing an insert at this point. However if I navigate off the record the update is called. there isn’t anything I can do to stop the update from happening if the user does not want to add a new record that I can find. I’m using

 DoCmd.GoToRecord , , acNewRec

To get the form to have all the text boxes go to a new record. At this point as soon as you start typing into any of the text boxes you can’t go back. The autonumber will incriment and I have sku builder that concatenates the autoNumber to a prefix to act as a serial number.

What I need to do, is figure out a way to get the update to cancel if the user clicks close. I’ve tried to disable close, but you can always right click the bar and select close from there. This, along with anything that prompts the form to close commits that in process record and subsequently fires the “afterUpdate” event. I read some Microsoft documentation and “form_unload” is called first in the workflow but insert always goes before that. I’ve also tried to use the “beforeUpdate” but that fires as soon as you attempt to write into one of the boxes and not right before “afterUpdate”

It seems there is a pretty huge hole in the space between beforeUpdate and afterUpdate. I don’t think this is a terribly complicated operation I’m trying to attempt here but perhaps I’ve been working on it for so long I have missed a simpler solution. I just need to cancel the insert operation or prompt the user that they are closing the form with an open record. If they hit no insert will fire, and yes it will.

Also, I have no appetite to rewrite for ADO because of my timeline. I just need to quickly throw some forms together and get it done. There are also a ton of fields that I don’t want to setup for an ADO insert. They are all built but I have this one issue that is giving me grief and I need to apply this solution to all the forms.

TLDR – Stopping a databound form from inserting if the user has entered text and tries to exit the form.

Solution Edit:
Change the form to modal/popup and disable close.
Add a button to handle close.
Add boolean flag

 Private Sub Form_BeforeInsert(Cancel As Integer)
 NR = True
 End Sub

Then add the code for the close button.

 Private Sub cmdClose_Click()
 Dim msgRes As VbMsgBoxResult

If NR Then
     msgRes = MsgBox("Do you want to save the current new record?", vbYesNoCancel, "Closing form...")
     If msgRes = vbYes Then
         DoCmd.RunCommand acCmdSaveRecord
         DoCmd.Close
     ElseIf msgRes = vbNo Then
         Me.Undo
         DoCmd.Close
     End If
 End If
 DoCmd.Close



 End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:09:57+00:00Added an answer on June 13, 2026 at 11:09 pm

    You can always do either a Me.Undo or DoCmd.RunCommand acCmdUndo on FormClose
    OR if you still can’t get it to work (I’ve spent a lot of time in Access and I know it can be finicky) you can do a DoCmd.RunSql ("Delete * from TableName where Id=NewID")

    You can also try this:

    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.Close , , acSaveNo
    

    You may also want to disable the close button and create a button to cancel the record so you can put all the code in there. If you set the form mode to a dialog you shouldn’t be able to right click close it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
I have a text area in my form which accepts all possible characters from
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.