Solved

Dirty property for control?

Posted on 2011-09-14
20
439 Views
Last Modified: 2013-11-28
Is there way to test the dirtiness of an individual control?  Controls have a Dirty event, but no Dirty property.

Mike
0
Comment
Question by:shacho
  • 11
  • 5
  • 2
  • +1
20 Comments
 
LVL 75
ID: 36540433
On Dirty is the Event ...  see image.

mx
Capture1.gif
0
 
LVL 75
ID: 36540437
0
 
LVL 75
ID: 36540442
OOPS ... I read the Q backwards.

Correct  ... no Dirty Property
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:shacho
ID: 36540448
>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
 
LVL 75
ID: 36540449
So ... instead:

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

mx
0
 
LVL 75
ID: 36540451
"But Controls have only the event."
Correct.
0
 

Author Comment

by:shacho
ID: 36540462

    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
 
LVL 75
ID: 36540481
"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
 
LVL 75
ID: 36540490
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
 

Author Comment

by:shacho
ID: 36540501
Ah - I didn't look closely enough.  But with "Me.txtYourTextBoxName" aren't you referencing (implicitly) the .Value property?  No?

0
 
LVL 75
ID: 36540530
"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
 
LVL 61

Assisted Solution

by:mbizup
mbizup earned 100 total points
ID: 36540535
You might want to look into the OldValue property as well:
http://msdn.microsoft.com/en-us/library/aa172955(v=office.11).aspx
0
 
LVL 42

Expert Comment

by:dqmq
ID: 36540540
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
 
LVL 42

Assisted Solution

by:dqmq
dqmq earned 100 total points
ID: 36540547
Oh yes, you need to refresh the tag properties in the form's after update event.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36540552
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
 
LVL 75
ID: 36540558
Problem with .OldValue is ... if field that control is bound to has never had a value, then .OldValue does not exist.

mx
0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 300 total points
ID: 36540562
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
 

Accepted Solution

by:
shacho earned 0 total points
ID: 36540586
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
 

Author Closing Comment

by:shacho
ID: 36558844
-
0
 
LVL 75
ID: 36540594

"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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question