Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Aug 6, 1997

A Form-Level DataChanged Property

Ever wished you could use the Save parameter outside of a Validate event? Have you noticed that if a bound control is changed and you set DataChanged back to False, Save is still true on Validate? Solve both problems by adding a public function:
 
Public Function FormChanged(frm As Form)
        On Error Resume Next
        Dim i As Integer, dChanged As _
                Boolean
        FormChanged = False
        For i = 0 To frm.Controls.Count - 1
                'for controls with no DataChanged 
                'property
                dChanged = frm.Controls(i)_
                        .DataChanged
                If Err <> 0 Then 
'almost certainly is
' OjectDoesntSupportThisPropertyOrMethod
                        Err = 0
                Else
                        If dChanged = True Then
                                FormChanged = True
                                Exit Function
                        End If
                End If
        Next
End Function
Use this function any time by simply writing If FormChanged(Me) Then, or however you wish, and you can use it in the Validate routine with Save = FormChanged(Me).
Matthew Brown
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date