473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Access 2007 form_BeforeUpdate Event does not fire

Fritz G
Hi I have a simple one table, one form MS Access 2007 DB. I want to have the data entry person verify their changes to a record before closing the form or moving to the next record only if any changes were made. I copied some VB code from MS KnowledgeBase (Article ID: 197103 ACC2000: How to Prompt User to Save Changes to Record in a Form for Access 2000) that works perfectly, but only one time. When I close the DB and reopen, the code no longer fires and I can make changes to any field on the form then move to the next record or close the form and those changes are immediately written to the table which is exactly what I want to avoid. Is this just a bug or am I missing something? I have tried to decompile then recompile but that didn't work. I can create a new blank DB then import the old DB and again the code will fire perfectly one time, as soon as I close the DB then reopen it the event code no longer fires. Any help would be greatly appreciated.


I pasted this code into the form_BeforeUpdate property.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2.  
  3.    ' This procedure checks to see if the data on the form has
  4.    ' changed. If the data has changed, the procedure prompts the
  5.    ' user to continue with the save operation or to cancel it. Then
  6.    ' the action that triggered the BeforeUpdate event is completed.
  7.  
  8.    Dim ctl As Control
  9.  
  10.    On Error GoTo Err_BeforeUpdate
  11.  
  12.    ' The Dirty property is True if the record has been changed.
  13.    If Me.Dirty Then
  14.       ' Prompt to confirm the save operation.
  15.       If MsgBox("Do you want to save?", vbYesNo + vbQuestion, _
  16.               "Save Record") = vbNo Then
  17.          Me.Undo
  18.       End If
  19.    End If
  20.  
  21. Exit_BeforeUpdate:
  22.    Exit Sub
  23.  
  24. Err_BeforeUpdate:
  25.    MsgBox Err.Number & " " & Err.Description
  26.    Resume Exit_BeforeUpdate
  27. End Sub
Jul 29 '10 #1

✓ answered by colintis

@Fritz G
Not really, you can first try setting the trust center correctly and it may give you the answer. Just keep in mind there may be some coding styles will not be accepted in 2007.

As the article you found for reference is for Access 2000, it may be better off to search with Access 2007 instead.

7 4431
NeoPa
32,556 Expert Mod 16PB
I don't know Access 2007 very well, but I know that it can be quite unhelpful sometimes when it blocks code from running. I can't tell you exactly where to look but it sounds as if your code is being blocked and you need to tell it to trust your project. Exactly what the steps are I'm afraid I can't tell you.

This means it's not a problem with the code as such, but with the settings that block the code from even starting.
Jul 29 '10 #2
Jerry Maiapu
259 100+
I am certain that your code will work perfectly well with MS access 2003 so just export your table and form to MS2003.

Just an idea
Passing by
Jul 30 '10 #3
thanks for quick replies, i guess i should give up on access 2007, but kind of a pain dealing with work station upgrades, i tried saving in 2003 format without success but only with 2007 client, i'll try full 2003 tomorrow, just seems like really simple VB should just work in 2007.
Jul 30 '10 #4
colintis
255 100+
@Fritz G
Not really, you can first try setting the trust center correctly and it may give you the answer. Just keep in mind there may be some coding styles will not be accepted in 2007.

As the article you found for reference is for Access 2000, it may be better off to search with Access 2007 instead.
Jul 30 '10 #5
missinglinq
3,532 Expert 2GB
To trust your folder, click:
  • Office Button (top left)
  • Access Options (bottom of dialog)
  • Trust Center (left)
  • Trust Center Settings (button)
  • Trusted Locations (left)
  • Add new location (button)
Welcome to Bytes!

Linq ;0)>
Jul 30 '10 #6
NeoPa
32,556 Expert Mod 16PB
I'm sure the idea of moving back to 2003 would work for you Fritz, but you should probably ask yourself first if this is really the direction you want to move in. Getting into a cul-de-sac is rarely good long-term thinking.

I wasn't suggesting earlier that this was a difficult problem to resolve. Simply that I didn't know the solution myself. It seems that others have already posted quite good solutions that should have you working in no time. I'm sure that's a better approach for you.
Jul 30 '10 #7
Wow! Thanks so much to all of you for the help. It looks like adding the directory where the DB lives to the "Trust center" has allowed to event code to fire each time now and this case is closed. Thanks again!
Jul 30 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: J.Marsch | last post by:
I must be missing something here: The Init event for controls does not seem to fire. What I did: Drop a textbox on a blank webform, hook the textbox's Init event. Code: this.Textbox1.Value =...
3
by: Jimmy | last post by:
Hi, I built a webform with a repeater: <asp:repeater id="rep1" runat="server" DataSource='<%# ar %>'> <ItemTemplate> <asp:Button Runat=server Text="<%# Container.DataItem %>" ID="Button1"...
11
by: OldProgrammer | last post by:
All the documentation and discussion I have read indicate that the Session_End is not supposed to fire unless you are in "inProc" Session state mode, and then only on Session Timeout or at Session...
1
by: Steve | last post by:
Looking for some help on this one... I have three servers (development, staging, production), each running the same code. All three computers are running Windows 2003 Server, IIS 6.0. I have...
7
by: denuk2003 | last post by:
Hi Everybody I have a 2003 application that I am trying to run under 2007, The code seems to work OK but the Ribbon is a big problem. It just takes up too much space away from the application. ...
16
by: google | last post by:
In a continuous form the following code is under a button in the form header. In Access 2003 and earlier, this goes to a new record, then adds relevant data to that new record. DoCmd.GoToRecord...
17
by: Neil | last post by:
A client of mine likes some of the new bells and whistles in Access 2007, and is thinking about converting our A03 format MDB to an A07 format file. However, while some of the users have A07, many...
1
by: Dennis | last post by:
I've noticed some old posts regarding this issue; but nothing recently and no resolutions in the old postings. Its almost hard for me to believe that this wouldn't be fixed by now. I am using...
5
by: WPW07 | last post by:
Hello, We have several complex applications developed in Access 2003 by various outside consultants. These applications link to a variety of Oracle tables and are used only for Access reports. ...
5
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.