Me.Dirty - Please help.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DanielM
    New Member
    • Feb 2007
    • 16

    Me.Dirty - Please help.

    Please Help - If Me.Dirty
    I Understood That It Check If any Data in controls had changed.
    I Have a Form with few textboxes, and On Exit from the form i want to check if data was changed. But It didn't work, Me.Dirty returned "false" although I changed data in textbox.
    the real reason, I understand now, it because the textboxes are in subform and the Exit button is at the main form, so me.dirty don't recognize changes in the subform.
    What can I do
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by DanielM
    Please Help - If Me.Dirty
    I Understood That It Check If any Data in controls had changed.
    I Have a Form with few textboxes, and On Exit from the form i want to check if data was changed. But It didn't work, Me.Dirty returned "false" although I changed data in textbox.
    the real reason, I understand now, it because the textboxes are in subform and the Exit button is at the main form, so me.dirty don't recognize changes in the subform.
    What can I do
    Declare the following Public Variable in a Standard Module:
    Code:
    Public blnDataChangedInSubForm As Boolean
    In the Dirty() Event of your Sub-Form:
    Code:
    Private Sub Form_Dirty(Cancel As Integer)
      blnDataChangedInSubForm = True
    End Sub
    In the Close() Event of your Main Form:
    Code:
    Private Sub Form_Close()
    If blnDataChangedInSubForm Then
      MsgBox "Data has changed in the Sub-Form"
      'Do other processing here if desired
    Else
      MsgBox "Data has not changed in the Sub-Form"
      'Do other processing here if desired
    End If
    End Sub

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32662

      #3
      You can also refer directly to the Dirty property of the subform (Referring to Items on a Sub-Form) :
      Code:
      If Me![SubformName].Form.Dirty Then

      Comment

      • DanielM
        New Member
        • Feb 2007
        • 16

        #4
        Thanks a lot to both of you.
        I will try .

        Comment

        • DanielM
          New Member
          • Feb 2007
          • 16

          #5
          Hello Neopa,
          I tried your suggestion, but it still returned 'false' although I made a change in a textbox. I wrote:
          If Me.cldCustomer. Form.Dirty Then
          (cldCustomer is the Name of The Child. The Name of the form in this child, he didn't recognize).
          Please help.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32662

            #6
            Originally posted by DanielM
            Hello Neopa,
            I tried your suggestion, but it still returned 'false' although I made a change in a textbox. I wrote:
            If Me.cldCustomer. Form.Dirty Then
            (cldCustomer is the Name of The Child. The Name of the form in this child, he didn't recognize).
            Please help.
            Is the CheckBox bound to the underlying Record Source?
            I think it would need to be to set the Dirty property.

            Comment

            Working...