Invalid Reference to the Property Dirty

jereece

Registered User.
Local time
Today, 23:35
Joined
Dec 11, 2001
Messages
300
I created a new database in Access 2007. The main form serves as a menu to open other forms and reports. After creating the whole thing, I wanted a button to close the database. So, at the bottom of the main form I added a Quit App button. To add this button I clicked on the button tool and let Access walk me through choosing Quit App as the action for clicking the button. Problem is when I test it, I get the error message "You entered an expression that has an invalid reference to the property Dirty".

You would think that having Access walk me through this simple task I would have avoided error messages. I deleted and recreated the button several times. I have done this many times in the past with no problem. Does anyone have any idea why I am getting the error message and how to fix it? All I want is a simple button to exit.

As always I appreciate the help.

Jim
 
I think Access is assuming that the for i bound so it wants tot save any changes before exiting.

I would try commenting put the code that uses the Me.Dirty

Is your database split? If not, I would recommend that you do. If split, I like to make my main menu form bound to a table so that it will create and keep the locking file.
 
By split do you mean that the data is in one file and the front end in another file? If so the answer is no. The data, forms and reports are all in the same database file.

I would try commenting put the code that uses the Me.Dirty
I am not sure what this means. However, I looked at the Event Procedure for the the On Click event. I removed the code " If Me.Dirty Then Me.Dirty = False" and now the button works. Do you see any potential problems with what I did?

Thanks,
Jim
 
Jim,

You did what I was suggesting. The way I was suggeting tht you remove the line was to make it a comment.

Example:

Code:
'   This is comment since it starts with an apostrophe ( ' )

' check to see if there any any changes to the bound field on the form
' if there are changes ( form is "dirty") then save them.

If Me.Dirty Then Me.Dirty = False

Re comment out a line of code:

Code:
' the next line will not execute since it is a comment
'  If Me.Dirty Then Me.Dirty = False


What this VBA code ( If Me.Dirty Then Me.Dirty = False ) is doing is checking to see if the form has any changes to data, the form's property is called "Dirty", and saving the changes is needed.

If you form doesn't have a record source ( unbound) then you should be fine with removing the "save".
 
Just delete it. I noticed it puts that in everytime it creates a Exit button. I just delete it out and keep going.:D
 

Users who are viewing this thread

Back
Top Bottom