William

MadeCurler

enthusiastic pensioner
Local time
Today, 06:24
Joined
Dec 6, 2007
Messages
49
I'm new (very new) why does this not work? I've attached it to the After_Update event of a Text Box to Enable/disable a Command Button

Sub UndoEdits()
If Me.Dirty Then
Me!btnUndo.Enabled = True ' Enable button.
Else
Me!btnUndo.Enabled = False ' Disable button.
End If
End Sub

I get the message "You have entered an expression that has an invalid reference to the property Dirty" ....what's "Me!" and "Me." all about?
 
I may be off here but, if you've entered something into a textbox that'll trigger the after update event won't the form always be dirty?

And in any case, you can't put a sub inside another sub.

You would be better off putting the code to enable the button directly into the on_dirty event of the form.

Code:
Private Sub Form_OnDirty()
Me.btnUndo.Enabled = True ' Enable button.
End Sub

and maybe use the on_current event of the form to disable the button when you move to a new record

Code:
Private Sub Form_OnCurrent()
Me.btnUndo.Enabled = False ' Disable button.
End Sub

Note: Make sure that the name of the command button is the same as in the code (i.e., btnUndo not something like Command1).
 
As Craig said, you can't place on sub inside of another sub! When you accidentally do, Access is apt to generate all sorts of odd error messages, even more enigmatic that ususal! The only situation that I know of where "You have entered an expression that has an invalid reference to the property Dirty" is a valid error message is when the form involved is unbound. An unbound form can never be Dirty, and hence the "invalid reference" message.

Linq
 

Users who are viewing this thread

Back
Top Bottom