Solved

Dirty property for control?

Posted on 2011-09-14
20
435 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

867 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

16 Experts available now in Live!

Get 1:1 Help Now