Solved

Dirty property for control?

Posted on 2011-09-14
20
434 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
 

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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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 - Access MVP)
DatabaseMX (Joe Anderson - Access MVP) 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now