Results 1 to 10 of 10
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919

    Conditional Formatting of a text-box

    On one of my forms, I want to change the Fore color based on the value of a table field. I have a Public Function named "Status" to which I pass two parameters.



    Expression Is Status("ID1","PA")=False

    There must be something wrong with the way I coded the conditional formatting, as the function "Status" never receives control. I would have thought that "Status" would be prefixed thus: =Status. However, I get a syntax error if I code the equals sign before the function name.

    How should such a reference be coded?

    Thanks,
    Bill

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    In a brief test:

    TestIt([Salary])

    worked passing a value to a function. Are you passing fields or literal text? You want the values bracketed if fields.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,962
    I did a test of Conditional Formatting calling a function and it worked. Can't reproduce issue. Put a breakpoint in the function, does it get executed?
    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.

  4. #4
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Paul,

    Expression should have been coded: Status([ID1],"PA")=False as ID1 is a field and "PA" is a literal.

    The function doesn't need to be invoked if ID1 = 0. How does one code the expression to account for that? If ID1 > 0 then IF Status([ID1],"PA")=False?

    And no June, with the expression being wrong the function never ran so there was no breakpoint honored.

    Thanks,
    Bill

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Personally I'd handle the ID1 value in the function, but you could use an IIf() as well.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,962
    Values were provided for both arguments so the function still should have run.

    However, issue resolved?
    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.

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Yes, that's where I'm in fact dealing with ID1 being zero. The function simply bounces back when ID1 = 0.

    Thanks,
    Bill

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    I must not be handling this properly, so I'll get out of the way.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,962
    Paul, I think your contribution to discussion was very relevant and lead to solution.
    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.

  10. #10
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Paul,

    My post must have been misleading. What I meant was that in that I didn't know how to test the value of ID1 within the conditional formatting statement that I had defaulted to what I know, namely to test the value of ID1 at the entry to the function and return immediately if ID1 is zero. So, your suggestion was right on and that's what I did.

    Sorry for the confusion,
    Bill

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

Similar Threads

  1. Replies: 7
    Last Post: 10-11-2012, 02:13 PM
  2. Replies: 5
    Last Post: 08-20-2012, 11:11 PM
  3. Replies: 1
    Last Post: 04-26-2012, 08:31 PM
  4. Conditional Formatting of Text Boxes
    By beribimba in forum Reports
    Replies: 2
    Last Post: 03-09-2012, 05:08 PM
  5. Replies: 0
    Last Post: 11-13-2009, 10:18 AM

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