Dirty Flag for unbound form
Posted by: fredometro on
Jan 15th, 2004 |
Filed under: MS-Access
The dirty flag doesn’t work when the form is unbound. Here the technique is to use the validation rule like an event in order to set the flag. Easy: A simple function returning the control’s text itself can do the job!
I bother for the performance so my code also checks for the existence of a former validation rule. Setting properties of many controls could make the form open slower without this check.
Once the form is first opened with this method, then saved, there is no need of re-doing the function so the form opens faster because for sure testing for the existence of SetDirty validation rule will make an exit.
Private Sub Form_Open(Cancel As Integer)
Dim ctr As Control
Dim frm As Form
Set frm = Me
For Each ctr In frm
On Error Resume Next
if ctr.validatonrule="SetDirty()" then ' Already done, let's not smash an open door!
exit sub
On Error Goto 0
if isempty(ctr.Validationrule) then
ctr.ValidationRule = "SetDirty()"
end if
Next ctr
End Sub
And, of course don’t forget the SetDirty function:
Public Function SetDirty()
IsDirty = True
SetDirty = Me.ActiveControl.Text
End Function
The full EE thread can be read here:
http://www.experts-exchange.com/Databases/MS_Access/Q_11879478.html.html
No related posts.

Tags:
Add A Comment
You must be logged in to post a comment.