Access Error - The macro or function set to the BeforeUpdate or ValidationRule property...

Hi,

I have an access database which has started to produce an error. On the machines form of the attached database, it audits any changes you make. It does this by calling a function from the BeforeUpdate event of the form, which then opens another form asking for more detail and giving the option to cancel the change.

In certain conditions a dialogue box appears stating the the BeforeUpdate property is preventing the field from being saved (I have attached a screen print of the actual error). So far my findings are:-

1. If you make a change to the Machine Information (top of the machines form) and press CTRL+Shift to save the record, the error does not appear.

2. If you make a change to the Machine Information and click on the Finish Editing button, the error does not appear.

3. If you make a change to the Machine Information and click on one the subforms the error DOES appear.

I have used breakpoints in the code to try and trap the specific point the error is happening but the error does not appear by stepping through the code. I have however narrowed it down to being the DoEvents part of the code which is in a While loop.

As I mentioned, I have attached the database in question, you will need to open the Machines form and click on the Edit Machines Settings button to make any changes and I have been using the No CPU's field for testing.

Any help would be much appreciated.

Thanks,

Mark
ServerDetailsDB.mdb
error.bmp
LVL 4
HarkinsAsked:
Who is Participating?
 
Jim Dettman (Microsoft MVP/ EE MVE)Connect With a Mentor President / OwnerCommented:
Mark,
  Just a quick update; I played around with this for a little over an hour yesterday and really got no where.  Can't figure out what is actually causing the problem.
  Generally, there are certain things you cannot do in the middle of a BeforeUpdate event (ie. goto the new record or set a control via it's text property).  But I can't see where your doing any of that and I'm not sure where the error is getting triggered.  I have narrowed it down to the popup form, but that's it.   It's not changing the fields  themselves; that works fine.
  But it definitely is a "timing issue" as I was talking about because placing a stop in the process let's the error go away.
  I had intended to get back to it with my focus shifting towards re-structuring the process rather then figuring out what exactly was wrong, but the day got away from me.
  From where the error occurs, I think the problem is in somehow the setting of the popup fields right after the open and then that wait loop with the DoEvents.
  What I generally do is open popups in dialog mode and pass any data in via the Openargs property.  No wait loop is needed then because code execution in the calling code stops until the popup is hidden or closed.  
  On the popup then, both the OK and cancel buttons simply set a flag and hide the form.  Then execution returns to the calling program and I can look at the form and carry out any logic.  So the popup does nothing more then gather info and validate that.
 I will try my best to get to this sometime today.  I know you asked this question almost a week ago and still don't have an answer.
JimD.
0
 
Kelvin SparksCommented:
You seem to get this error when you click into the subform. This is moving from the main form record to the subform and attempts to write the main form record (calls the before update). Does Ctrl Shift or the Finish Editing button undertake any processes that the before update doesn't?

Moving to a subform has much the same effect on the main record and closing the form.


Kelvin
0
 
HarkinsAuthor Commented:
Hi Kelvin,
No there is nothing different between any of the methods as far as I am aware. There is only code running on the BeforeUpdate of the form which is triggered when you close/finish editing/ctrl+shift the form.
Mark
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
Kelvin SparksConnect With a Mentor Commented:
Hmmm

I just played with your form. I could edit the person name - changed from Bob to Fred (oor the other way round and then clicked into the subforms - tried twice and went to different subform each time.

Your audit process appeared as expected - I did not click any save/finish buttons.

Different to what you indicate above??

Kelvin
0
 
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
<<I have used breakpoints in the code to try and trap the specific point the error is happening but the error does not appear by stepping through the code.>>
This is a sure tip-off that you have two events occuring at the same time that interfer wiith one another. You see this in a lot of apps when they get moved to a faster/slower machine and the order of the events change.  Works fine on one or in a specific sequence of events, then blows up with an error latter.
<<I have however narrowed it down to being the DoEvents part of the code which is in a While loop.>>
I haven't looked at your DB yet, but you should not be having to do that. I'm a little busy at the moment, but I'll look at it some time this morning unless someone else gives you an answer before then,
JimD.
0
 
Kelvin SparksCommented:
Regret, I'll have to leave this tonight (after midnight in NZ, and I have a 6.30 start this morning.


Good luck


Kelvin
0
 
HarkinsAuthor Commented:
Yes that is different from what I am getting. When I change something in the Machines from, such as the persons name, then straight after click into a subform, such as the Network Cards subform, the ConfigChanges form appears but so does the error mentioned above.
I will have a go at testing it on another machine as post my results! For what it is worth I am using Access 2003 with Service Pack 3 installed.
Mark
0
 
Kelvin SparksCommented:
I am using 2003 SP2. Refuse to have SP3 for Access - allow it for other Office Apps


Kelvin
0
 
HarkinsAuthor Commented:
Hi guys! Sorry for the delay in getting back, its been a holiday weekend so not been able to try it out!
Anyway, I have tried it on a couple of computers now and I still get the same results which is the error appearing! What your saying Jim certainly makes sense, I just dont know how to fix it!
The only thing I have not been able to do is test the database on a machine that is not running Office SP3!
Mark
0
 
HarkinsAuthor Commented:
Update: I have now tested this on another computer without any Office Service Packs installed and I still get the error.
0
 
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
Mark,
  This is not something wrong with Access, but with your app.  I'm taking a look at it now.
JimD.
0
 
HarkinsAuthor Commented:
Thanks Jim!
0
 
HarkinsAuthor Commented:
Thanks for your time Jim. It is a strange one!
Cheers,
Mark
0
 
HarkinsAuthor Commented:
Hi guys, thanks for the time you spent on this and your suggestions.

I moved some of the code around to ensure that it would always run in a logical order.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.