Solved

Dirty property for control?

Posted on 2011-09-14
20
440 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

752 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