Results 1 to 7 of 7
  1. #1
    Remster is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    317

    Conditional Formatting through VBA: On Undo


    Folks

    I've moved all my conditional formatting to VBA because of performance issues with Access's built-in conditional formatting facility, but there's one feature I can't replicate. Some of my formatting involves highlighting fields if they're blank. This works fine for On Current and After Update, but I can't get it to work for On Undo: if I undo changes and thereby leave a field blank, I can't get the conditional formatting to kick in again. Am I missing something about On Undo, or is there another way of doing this?

    Thanks

    Remster

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    I don't know if you are or not bud, but could you check NULL in a field AND apply one of the conditions in the conditional formatting collection?? that's another solution for you.

  3. #3
    Remster is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    317
    No, that's not how I'm doing it. I've read that it would perform in the same way as the built-in conditional formatting facility (plus it looks complicated). I'm just using this sort of thing:
    Code:
    If IsNull(Forms!Form1!Field1.Value) Then
        Forms!Form1!Field1.BackColor = 65535
    Else
        Forms!Form1!Field1.BackColor = -2147483643
    End If
    The problem is that it doesn't work in On Undo.

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    are you sure you're understanding exactly when the UNDO even fires?? I don't even know...

  5. #5
    Remster is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    317
    Yeah, I've got that bit covered. I've even discovered that I can get the format to change if I omit the condition 'If IsNull(Forms!Form1!Field1.Value)', which tells me that Access doesn't recognise the undone field as null (or empty – I've tried "" too). Oddly, though, if I navigate away from and back to the record, it is recognised as null for the purposes of the On Current event!

  6. #6
    Remster is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    317
    Nailed it. Rather than
    Code:
    If IsNull(Forms!Form1!Field1.Value) Then ...
    I need
    Code:
    If IsNull(Forms!Form1!Field1.OldValue) Then ...
    Evidently the event fires between my clicking on the Undo button and the field's being returned to its previous state.

  7. #7
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    wow! I don't think I helped at all. What a consulting job I did...

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

Similar Threads

  1. Conditional Formatting
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-30-2010, 09:31 PM
  2. conditional formatting right(..)
    By bbeernaert in forum Access
    Replies: 3
    Last Post: 08-25-2010, 12:33 AM
  3. Conditional Formatting
    By DanOzDirect in forum Reports
    Replies: 3
    Last Post: 07-21-2010, 08:49 PM
  4. Conditional Formatting
    By cevatyildiz in forum Forms
    Replies: 8
    Last Post: 04-30-2010, 12:01 PM
  5. Conditional formatting
    By ylivne in forum Reports
    Replies: 1
    Last Post: 07-12-2009, 06:18 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