Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Me.Dirty confusion

Me.Dirty confusion

Me.Dirty confusion

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?

RE: Me.Dirty confusion

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.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close