Results 1 to 5 of 5
  1. #1
    newbieX is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    111

    Dirty event not activating on Access 2007 form

    I have a bound pop up form with a Clear data button. It runs the Undo command.
    The Form_Current event sets this button's enable property to False.
    The Form_Dirty event sets this button's enable property to True.

    The button's property is always set to False even after I enter data into the form. I think this is because my Form_Load event is populating two fields. One is passed from the main form as an OpenArgs, the other is the unique ID which is calculated based on the OpenArgs value.



    Any suggestions as to how to get the Dirty event to activate under these circumstances? If not, then an alternative approach perhaps?

    Thanks in advance.
    Code:
    Private Sub cmdUndoChanges_Click()
    
        CustID_temp = Me!CustID
        FacNo_temp = Me!Unique_ID
    
        DoCmd.RunCommand acCmdUndo
    
        Me!CustID = CustID_temp
        Me!Unique_ID = FacNo_temp
    
    End Sub
    
    Private Sub Form_Current()
        Me!cmdUndoChanges.Enabled = False
    End Sub
    
    Private Sub Form_Dirty(Cancel As Integer)
        Me!cmdUndoChanges.Enabled = True
    End Sub
    
    Private Sub Form_Load()
    Dim test As Integer
    
        Me!CustID = OpenArgs
    
        test = DCount("Unique_ID", "tbl_Table2", "CustID = '" & Me!CustID & "'")
        If IsNull(Me!UNIQUE_No) Then
            test = test + 1
            Me!Unique_ID = CustID & "-" & test
            MsgBox "No Previous Data"
        Else
        ' these will be turned back on depending on whether the user selects the
        ' modify data button or add new data button.
            For Each ctl In Me.Controls
            Select Case ctl.ControlType
            Case acTextBox, acComboBox, acOptionGroup, acCheckBox
                ctl.Locked = True
                ctl.BackColor = 15066597
                Box40.BackColor = 15066597
            End Select
            Next ctl
        End If
    
    MsgBox Me!Unique_ID
    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,048
    Dont use it (Dirty). Its a headache.

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,863
    Have you tried saving the record in the On Current Event?
    if me.dirty then me.dirty = false

  4. #4
    newbieX is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    111
    Awesome. That did the trick. Thanks a zillion.

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,863
    You bet...

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 12-12-2013, 10:13 PM
  2. Event Handlers for Pivot Tables [Access 2007]
    By anozir in forum Programming
    Replies: 3
    Last Post: 06-25-2013, 01:32 PM
  3. On Dirty fires but Me.Dirty = False (v2010)
    By Rod in forum Programming
    Replies: 5
    Last Post: 07-30-2011, 08:42 PM
  4. Buttons activating on form startup
    By howieyo in forum Forms
    Replies: 0
    Last Post: 06-13-2011, 06:48 PM
  5. can anybody explain dirty event to me?
    By RedGoneWILD in forum Programming
    Replies: 3
    Last Post: 08-05-2010, 01:50 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums