Event problem

BeeJayEff

Registered User.
Local time
Today, 00:53
Joined
Sep 10, 2013
Messages
198
On a subform, I have a text box control with an AfterUpdate event handler. The subform itself has an AfterInsert event handler.

If a user enters data into that tb control for a new record and then moves on (tab or click elsewhere), the AfterUpdate fires and does what it should, including setting Me.Dirty=False immediately before it completes. Then the form's AfterInsert event fires and does what it should, but finishes by returning program control to the ErrorHandler label within the control's AfterUpdate routine, reporting either an error 2101 (The setting you entered isn't valid for this property) or 3270 (Property not found). The form's AfterInsert handler does have its own ErrorHandler label, but it is not being executed.

Any ideas why this might be happening ... and what can I do to fix it ??
 
Any ideas why this might be happening
There is something wrong with your code

and what can I do to fix it ??
Use the debugger and immediate window to track the various values to see what is causing the problems. Or you could post your code here and maybe we can help. If you do, Please use the code tags (# button) you will find on the advanced editor to preserve the spacing and indents of your code so it is easier to read
 
There is something wrong with your code
That is indeed possible. I'm hoping that the symptoms might ring a bell with someone.

Use the debugger and immediate window to track the various values to see what is causing the problems.
I've done that, all the database field values and variables are as expected. Are there particular environment/system values you recommend I inspect ?

Or you could post your code here and maybe we can help. If you do, Please use the code tags (# button) you will find on the advanced editor to preserve the spacing and indents of your code so it is easier to read
It's a lot of code, which is commercially sensitive. Anonymising it and stripping out irrelevant sections while keeping whatever is necessary to preserve the bug would be very time-consuming.
As I said, I'm hoping that someone will have seen something similar - an event handler using another's error handler.
 
Sorry, in that case I don't think I can help - the errors you are getting could apply to a number of things and the error message speaks for itself.

Suggest you google 'vba error 2101' to see if you can find a more detailed explanation where people have actually had this problem - you may recognise a similar scenario to what you are trying to do
 
Have you set a breakpoint and stepped through? Sometimes code jumps from one event to another more than you ever expect, and that may be how you're ending up somewhere else...
 
How is the subform related to the mainform?
I did a little googling and see that others have experienced 2101 errors with subform activity. There doesn't seem to be a single cause, but there are suggestions that the business logic/saving a record may be at fault.
These links may offer some help.
http://office.microsoft.com/en-us/access-help/order-of-events-for-database-objects-HP005186761.aspx
http://stackoverflow.com/questions/...ccess-when-i-have-a-button-to-save-a-record-o

If you do find a solution, please post back as it seems to be somewhat elusive.
 
Well I'm afraid that this one is going to remain a mystery. I tidied up some of the code and the problem seems to have gone away. I removed a couple of cases of "If me.dirty then me.dirty= false" statements, which I think might have been causing partially complete records to be saved and might be something to do with it.
 

Users who are viewing this thread

Back
Top Bottom