Notifications for controls change

Posted on 2002-04-21
Last Modified: 2010-05-18

instead of using the onChanged event for each one of the controls on a form, Somebody told me that there is a way to know if one of the controls on a form has changed !

Does sombody know about a property or control that gives you that information ?

Question by:Ronnie_Shmuel
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
  • 2

Expert Comment

ID: 6957677
You can set the Tag property of objects when you load a form.  For example to set the tag property when a form loads:

Private Sub Form_Load()
Dim obj As Object

For Each obj In Me
    If TypeOf obj Is TextBox Then
        obj.Tag = obj.Text
    End If
End Sub

Then you can check to see if that property has changed:

Private Sub Command1_Click()
Dim obj As Object

For Each obj In Me
    If TypeOf obj Is TextBox Then
        If obj.Tag <> obj.Text Then
            MsgBox obj.Name & " has changed!"
        End If
    End If

End Sub

Tweak the code to get it to fit your needs.
LVL 15

Accepted Solution

ameba earned 50 total points
ID: 6958028
There are 4 ways to see if something has changed:
uses ctrl.DataChanged

Author Comment

ID: 6959419
the datachange prop. doesn't work for all the controls but it's enough for me.

The code below show an example:

Private Sub Command1_Click()
    Dim ctrl As Control

    For Each ctrl In Screen.ActiveForm.Controls
        If TypeOf ctrl Is TextBox Then
            If ctrl.DataChanged = True Then
                MsgBox "Changed"
                ctrl.DataChanged = False
            End If
        End If
End Sub
LVL 15

Expert Comment

ID: 6959492

Featured Post

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!

Question has a verified solution.

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

Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

732 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