Solved

Notifications for controls change

Posted on 2002-04-21
4
150 Views
Last Modified: 2010-05-18
Hi

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 ?

TNX
0
Comment
Question by:Ronnie_Shmuel
  • 2
4 Comments
 
LVL 4

Expert Comment

by:RichW
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
Next
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

Next
End Sub

Tweak the code to get it to fit your needs.
Cheers,
RichW
0
 
LVL 15

Accepted Solution

by:
ameba earned 50 total points
ID: 6958028
There are 4 ways to see if something has changed:
http://www.vb2themax.com/Item.asp?PageID=TipBank&ID=38

http://www.vb2themax.com/Item.asp?PageID=TipBank&ID=416
uses ctrl.DataChanged
0
 

Author Comment

by:Ronnie_Shmuel
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
    Next
   
End Sub
0
 
LVL 15

Expert Comment

by:ameba
ID: 6959492
Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
LINQ return type for nested group query 6 72
Excel - Save a copy of work book 13 83
vb6 connector to SQL Server 2 34
Prevent user closing word document opened with VB6 6 67
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

896 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

12 Experts available now in Live!

Get 1:1 Help Now