none
Me.Dirty not being set to True for changed field RRS feed

  • Question

  •   I have a field on my form that is bound to the table.  When I change any field on the form, when I debug the module Me.Dirty is equal to TRUE.  Yet for just 1 of the fields, no matter what I change for this field, Me.Dirty is always FALSE.  It is the last field on the form.  I change the field before it and any 1 field on the screen, then Me.Dirty is TRUE.  When I change this 1 field, Me.Dirty is always set to FALSE.  Can someone give some idea or reason why this is.  Everything else works great, but this 1 field is causing me many headaches.

      I look forward to hearing any ideas/thoughts on this matter.  Thanx in advance.  The logic is:

        If Me.Dirty Then
            Me.Dirty = False
            RecordHasChanged
        Else
            MsgBox "No changes have neen made to the current record.", vbExclamation, "Invalid Operation"
        End If

    Wednesday, March 6, 2019 9:16 PM

Answers

  •   I have found the challenge or what I think is the work around.  I do not like it, but it works consistently.  There may be a better way to handle this and if someone knows, plz pass on.

    1.  I am using a continuous form to display multiple records from the file based on a criteria.  The last field in the recordset is the secdep field.  The first field is the sir_rate_36 of each record in the recordset.

    2.  I enter the criteria and get the records.  I make a change to the secdep field and press tab.  The cursor goes to the first field sir_rate_36 of the next record on the form.  I press the update_all button, but Me.Dirty is false and does not update anything, although I changed the secdep on the first record.

    3.  Now what I did as the work around.  I entered the criteria and got the records.  I make a change to the secdep field and press tab.   The I moved the cursor back to any field in the 1st record, getting off this 2nd record.  Then I pressed the update_all button.  Now Me.Dirty is True and updates the records as it should.

      Therefore, in my analysis and testing, when I want to update_all, I have to stay on the 1st record in the continuous form when making the changes and I want to apply them to all the other records.  This works and not sure why it is this way, but it will update the way I have coded it to work.  Hope this make sense and it could help someone else.

      Thanx for assistance!

    • Marked as answer by ballj_351 Thursday, March 7, 2019 1:27 AM
    Thursday, March 7, 2019 1:27 AM

All replies

  • Hi. I think the Dirty property of the Form is changed on the first instance a change is initiated. Any succeeding changes does not affect the Dirty property anymore - until it is reset.
    Wednesday, March 6, 2019 9:26 PM
  • I just closed the form.  When I went to the field in question, changed it and checked Me.Dirty and it was false.  Exited the screen.  Started up Access, went to another field and changed it.  Performed a check on Me.Dirty and it was set to True.  It is only against this one field!
    Wednesday, March 6, 2019 9:59 PM
  • I just closed the form.  When I went to the field in question, changed it and checked Me.Dirty and it was false.  Exited the screen.  Started up Access, went to another field and changed it.  Performed a check on Me.Dirty and it was set to True.  It is only against this one field!

    When you say "field in question," is it a bound control? How exactly are you checking if the form is dirty? Have you tried using the Dirty event?
    Wednesday, March 6, 2019 10:28 PM
  • Yes it is a bound control.  The is a button I created called update_All and when it is clicked on the event triggers as follows and here is the code:

    Private Sub cmdUpdateAll_Click()
    On Error GoTo Error_Handler
    '
    ' Save to Manfacturer table
    '
        If Me.Dirty Then
            Me.Dirty = False
            RecordHasChanged
        Else
            MsgBox "No changes have neen made to the current record.", vbExclamation, "Invalid Operation"
        End If
    '

    '  rest of the code here.

    '

    Wednesday, March 6, 2019 10:37 PM
  • Are you able to share your db? I am not sure I understand the problem. How exactly are you checking if Dirty is True or False. Also, which field works and which one doesn't?
    Wednesday, March 6, 2019 10:43 PM
  • I have no problem with that.  Yet, the db and forms are split.  I wish we could do this over TeamViewer, since then it will be easier to show you and understand what is going on.  Are you okay with that
    Wednesday, March 6, 2019 10:48 PM
  • Sure. TV is fine. When?
    Wednesday, March 6, 2019 11:00 PM
  • Can you do 7:30pm EST?
    Wednesday, March 6, 2019 11:10 PM
  •   I have found the challenge or what I think is the work around.  I do not like it, but it works consistently.  There may be a better way to handle this and if someone knows, plz pass on.

    1.  I am using a continuous form to display multiple records from the file based on a criteria.  The last field in the recordset is the secdep field.  The first field is the sir_rate_36 of each record in the recordset.

    2.  I enter the criteria and get the records.  I make a change to the secdep field and press tab.  The cursor goes to the first field sir_rate_36 of the next record on the form.  I press the update_all button, but Me.Dirty is false and does not update anything, although I changed the secdep on the first record.

    3.  Now what I did as the work around.  I entered the criteria and got the records.  I make a change to the secdep field and press tab.   The I moved the cursor back to any field in the 1st record, getting off this 2nd record.  Then I pressed the update_all button.  Now Me.Dirty is True and updates the records as it should.

      Therefore, in my analysis and testing, when I want to update_all, I have to stay on the 1st record in the continuous form when making the changes and I want to apply them to all the other records.  This works and not sure why it is this way, but it will update the way I have coded it to work.  Hope this make sense and it could help someone else.

      Thanx for assistance!

    • Marked as answer by ballj_351 Thursday, March 7, 2019 1:27 AM
    Thursday, March 7, 2019 1:27 AM
  • Also, what I did was create a dummy field to tab to after I modified the last field on each record, this way I would not have to use the cursor to stay on the record.  I can enter a value in the last field, press tab and then do an update_all.
    Thursday, March 7, 2019 1:38 AM
  • Hi. Actually, when you tab from the last field on a record and the cursor goes to the first field of the next record, the record is automatically saved and the Dirty property is reset. So, by adding a "dummy" field to accept the cursor after tabbing out of the last field, you are staying on the same record and therefore Dirty is not reset. Good luck!
    Thursday, March 7, 2019 3:31 AM