Results 1 to 2 of 2

Thread: Me.Dirty (2000)

  1. #1
    2 Star Lounger
    Join Date
    Oct 2004
    Location
    Evansville, Indiana, USA
    Posts
    111
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Me.Dirty (2000)

    I am trying to use the Me.Dirty command. Here is my code: (thanks to Francois)
    Private Sub btnReturn_Click()
    If Me.Dirty Then
    If MsgBox("Do you wish to save this record before exiting?", vbYesNo + vbQuestion) = vbYes Then
    DoCmd.RunCommand acCmdSaveRecord
    Else:
    Me.Undo
    End If
    End If
    DoCmd.Close
    End Sub

    My problem is that the data entry occurs in a subform (frmEntrySub) and the button is on frmTime. Even though the subform is "dirty" it still says the record when I click btnReturn.
    Any suggestions?

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Me.Dirty (2000)

    That isn't going to work because the minute the focus leaves the subform (when you click on the button on the main form), the record gets saved. That's the way Access works. If the subform record has the required information in it, why would you not save it? If you need to do validation on the data before saving or undoing the record, put the validation into the BeforeUpdate event of the subform. Then it will fire any time the user tries to move off the record but before it is saved.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •