Results 1 to 3 of 3
  1. #1
    tariq1 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Posts
    16

    onDirty Code

    Hi,



    I am trying the code below, embedded within the OnDirty Event of teh form, so that when there is a change in form details the
    command button is enabled,

    however I seem to receive this error message when making an entry into a field

    'The expression onDirty you entered as the event property setting produced the following error:
    Procedure declaration does not match description of event or procedure having the same name'



    Code:
    Private Sub Form_Dirty()
        If Me.Dirty Then
            Me!btnUndo.Enabled = True     ' Enable button.
        Else
            Me!btnUndo.Enabled = False    ' Disable button.
        End If
    End Sub

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    The event procedure declaration is incomplete. Should be:
    Private Sub Form_Dirty(Cancel As Integer)

    The code doesn't make sense to me. Won't the procedure trigger only when the form is dirty so the True condition will always be returned and the control will never disable?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Actually, the code makes no sense to anybody!

    After getting your Sub Declaration straightened out, in the Form_Dirty event you only need the one line

    Me!btnUndo.Enabled = True ' Enable button.

    Then, in the Form_Current event, you need

    Me!btnUndo.Enabled = False

    to 'reset' the state of the button.

    Linq ;0)>

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

Similar Threads

  1. Word code in Access - How to modify my current code
    By Alexandre Cote in forum Programming
    Replies: 0
    Last Post: 11-15-2010, 08:26 AM
  2. Code in combobox, code in text box
    By float in forum Forms
    Replies: 3
    Last Post: 09-29-2010, 07:12 AM
  3. Access 2003 code vs Access 2007 Code
    By ralphjramirez in forum Access
    Replies: 5
    Last Post: 11-23-2009, 12:33 PM

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