Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 453
  • Last Modified:

Dirty property for control?

Is there way to test the dirtiness of an individual control?  Controls have a Dirty event, but no Dirty property.

Mike
0
shacho
Asked:
shacho
  • 11
  • 5
  • 2
  • +1
4 Solutions
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
On Dirty is the Event ...  see image.

mx
Capture1.gif
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
OOPS ... I read the Q backwards.

Correct  ... no Dirty Property
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
shachoAuthor Commented:
>Controls have a Dirty event, but no Dirty property.
By this I mean, Forms have a Dirty Event AND a Dirty Property.  But Controls have only the event.
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
So ... instead:

    If Nz(Me.Text0, "") = "" Then
        'not Diry
    Else
        ' Dirty
    End If

mx
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
"But Controls have only the event."
Correct.
0
 
shachoAuthor Commented:

    If Nz(Me.Text0, "") = "" Then
        'not Diry
    Else
        ' Dirty
    End If

This is in fact what I'm using now, but it makes me nervous because .Text is only a property of texboxes and comboboxes.  What about other controls?  Or is the concept of "dirty" really only applicable to controls that have transient values on the way to commitment (i.e. text and combo boxes).

Mike
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
"Text is only a property of texboxes and comboboxes."

No no ...Text0  is the Name of the Text box - better example:


    If Nz(Me.txtYourTextBoxName, "") = "" Then
        'not Dirty
    Else
        ' Dirty
    End If

    If Nz(Me.txtYourListOrComboBoxName, "") = "" Then
        'not Dirty
    Else
        ' Dirty
    End If

mx
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
I wasn't using the .Text property ...

Or ... I suppose ... if you want to use the .Text Property:


    If LEN(Me.txtYourListOrComboBoxName.TEXT) = 0 Then
        'not Dirty
    Else
        ' Dirty
    End If

Depending on when and where you are testing this.

0
 
shachoAuthor Commented:
Ah - I didn't look closely enough.  But with "Me.txtYourTextBoxName" aren't you referencing (implicitly) the .Value property?  No?

0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
"aren't you referencing (implicitly) the .Value property?  No?"

Yes ... which is the Default Property ... thus not necessary to explicitly state.

And that code works After the control has been updated (or not) ... ie, not while characters are being typed - in which case the .TEXT prop would be used.

However, in 19 years now ... this has never been an issue ... No Dirty property, because you can always make those tests.

mx
0
 
mbizupCommented:
You might want to look into the OldValue property as well:
http://msdn.microsoft.com/en-us/library/aa172955(v=office.11).aspx
0
 
dqmqCommented:
In the Form's on current event, move me.controlname.value to me.controlname.tag.  Thereafter, compare me.controlName.value to me.controlName.tag to see if it has changed.
0
 
dqmqCommented:
Oh yes, you need to refresh the tag properties in the form's after update event.
0
 
mbizupCommented:
If a value of a control is not equal to the OldValue, then I'd think the control is 'dirty'.  I haven't tested this, but it seems like it would work up until the point that the record is commited.
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Problem with .OldValue is ... if field that control is bound to has never had a value, then .OldValue does not exist.

mx
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Mike ... also, if the Form's Dirty property is not equal to True ... then all of the tests above are not relevant.

So again, to some extent ... it depends on where and when you make these tests.

mx
0
 
shachoAuthor Commented:
Now that I've thought this through more clearly, I really am only interested in those transient values (.Text).  For all other control types, any change is committed immediately.  I'm trying to revise how the form responds to the escape key:

On "escape":
If control is dirty then undo control
  else if form is dirty then undo form
    else unload form

By "dirty" in the first scenario, I really mean "some characters have been typed into the input frame", which of course can only happen in a text or combo box.

Thanks all for your comments.

Mike

0
 
shachoAuthor Commented:
-
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:

"On "escape":
If control is dirty then undo control
  else if form is dirty then undo form
    else unload form"

But hitting the Escape key pretty much already does that.

And if you are saying that if Form is not Dirty and user hits Escape and form closes ... I personally would not recommend that from a UI standpoint, as that is not normal Windows behavior.

mx
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 11
  • 5
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now