Results 1 to 12 of 12
  1. #1
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328

    Dirty problem with numbers

    I have a simple continuous form. Two text fields and one number (single format) field. When I close the form, I want a message to be generated if any field has been changed.

    The code for the close button is:

    If me.dirty then
    msgbox "my message"
    end if
    docmd.close.



    Weird event is that if text fields are changed, works fine. If change is made in number field, it doesn't sense the form as being dirty.

    Anyone know what is going on? Happens in both access 2003 2007

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I tested your code and it works for me when editing a number type field. Can't replicate the issue. However, am testing with Access 2010 right now but expect would be same for 2007.
    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
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  4. #4
    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
    This really needs to be done in the Form_BeforeUpdate event, not in the Form_Close event. Assuming that you only want this message to pop up if data on an existing Record has been changed, all you'd need would be:

    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
      If Not Me.NewRecord Then
        Msgbox "My Message"
      End If
    End Sub


    There's no need to check whether or not the Form has been Dirtied; if it hasn't been Dirtied, the Form_BeforeUpdate event won't fire!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    Quote Originally Posted by June7 View Post
    I tested your code and it works for me when editing a number type field. Can't replicate the issue. However, am testing with Access 2010 right now but expect would be same for 2007.
    Thanks much. After your response, I recreated the source table and form in a new db file to see if some bug in old objects. I then opened and closed the new form about 50 times and changed the value in the number field on each opening. Now, it seems to work except that in about one in about 10-15 testing open-close cycles, it still doesn't sense dirty state when I change a number value. Maybe I should reload Access or at least run repair? Frustrating.

  6. #6
    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
    What event are you using for the code at this time?

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  7. #7
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    [QUOTE=Missinglinq;158281]This really needs to be done in the Form_BeforeUpdate event, not in the Form_Close event. Assuming that you only want this message to pop up if data on an existing Record has been changed, all you'd need would be:

    The form is a popup that allows the user to change some factors that could affect values on the main form. The message reminds him to take certain actions if he has made any changes. It is a more efffective message if it displays the reminder just as he closes the popup to go back to the main form. Plus, if he makes more than one change, the repeated message could be annoying.

  8. #8
    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
    The Form_BeforeUpdate will only pop once, when the Record is saved, which occurs when the close the Form. I'd still try it in that event.
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  9. #9
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    I checked it and, on my system (A2007), Form_BeforeUPdate (and Form_AfterUpdate) pop a message as soon as a change is made on any control.

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I also have now tested with A2007. The Form procedures trigger only when record is committed by closing form or moving to another record. I don't know what is going on with your form. If you want to provide db for analysis, follow instructions at bottom of my post.
    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.

  11. #11
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    Thanks for following through on this. The BeforeUpdate does respond as you described. But, moving to another record(s) on the form is just what will happen 50% of the time it is used, so a pop up on each move would be annoying. I want the message to fire only when the popup form is closed and only if a change had been made (me.dirty) to one or more of the fields.

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I am confused. I think that is the behavior I am getting. Can't replicate your issue. If you want to provide db for analysis, follow instructions at bottom of my post. However, I won't be able to work with it for two weeks starting tomorrow.
    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.

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

Similar Threads

  1. Importing numbers from txt with thousands separator problem
    By poltroller in forum Import/Export Data
    Replies: 7
    Last Post: 09-16-2012, 01:58 PM
  2. Replies: 1
    Last Post: 11-29-2011, 08:43 AM
  3. Me.Dirty not catching
    By Ashe in forum Forms
    Replies: 4
    Last Post: 10-27-2011, 11:30 AM
  4. On Dirty fires but Me.Dirty = False (v2010)
    By Rod in forum Programming
    Replies: 5
    Last Post: 07-30-2011, 08:42 PM
  5. Dirty
    By JEPEDEWE in forum Programming
    Replies: 1
    Last Post: 11-13-2010, 04:50 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