Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Me.Dirty confusion

Status
Not open for further replies.

VicM

Programmer
Sep 24, 2001
444
US
Folks,
This by no means is a very critical problem. It's more annoying than anything else as it doesn't impact the user, just the developer (me!). LOL

Using Access 2010 on Win7 Pro box.

On my form I have a BeforeUpdate event. Whenever I try switching from the active form to design mode, the BeforeUpdate event is triggered and the message indicates that the "expression refers to an object that is closed or doesn't exist". The expression is testing if data was entered into some of the controls using the Me construct for the controls. If new data is being input, I want to ensure that certain fields are filled in as well.

If all I've done is open the form, change nothing and attempt to move to design mode, I get that error. So I've put some Debug.Print text in both the OnCurrent and BeforeUpdate events identifying the event and the status of the Dirty parameter.

If I move the record in the active form to the next record, I get the following info in the Immediate window:
From OnCurrent Dirty = False​
From BeforeUpdate Dirty = True​
From OnCurrent Dirty = False​

If I don't move to another record after first opening the form and attempt to move to design mode, I get the following in the Immediate window:
From BeforeUpdate Dirty = True​

Additionally, when this happens, the Debug.Print line is executed in the BeforeUpdate event (it's the first line of code in the event). The Debug.Print contains the Me.Dirty parameter. Yet the very next line of code which contains the Me.[control] If statement is where the cursor stops when I ask to Debug the error.

I'm confused as to why in the first circumstance the OnCurrent reports False for Dirty while the BeforeUpdate reports True.

Again, this only affects me when designing. It's not an issue for the user.

Any thoughts?
Thanks,
Vic
 
Solved the problem.

Because my Current event did some hide/show, enable/disable on a couple of controls based on the value of an option box, that set the Dirty parameter to True even tho no actual data was input.

When I tested the Dirty parameter in the Current event, I had the line of code at the beginning of the event. But when I added another Debug.Print line at the end of the Current event, it showed the Dirty parameter as True.

So I can use this info to get around the error condition.

Thanks,
Vic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top