Results 1 to 7 of 7
  1. #1
    MatthewGrace is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2013
    Posts
    159

    Why doesn't this Conditional Formatting work??

    Thank you for considering my question.

    I have 2 textboxes. The first one (txtTestThis) says Matthew. The second one (txtFormatThis) I want to Conditionally Format to red text if the first one says Matthew. It doesn't work, as you can see in the photo.



    FYI: This form is unbound and I wish to keep it that way. I want to conditionally formatting based on control values - NOT fields in a recordset.

    Thank you guys for any help!


    Click image for larger version. 

Name:	FormatTest.png 
Views:	20 
Size:	15.0 KB 
ID:	46817

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Try:

    [txtTestThis]="Matthew"
    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
    MatthewGrace is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2013
    Posts
    159
    Thank you June!
    I haven't used Access in a long time so I forgot these things.

    I have a bonus question. Suppose that txtTestThis were changed to a combobox called "cboTestThis". Could I test column2?

    I say this because in a situation where a combobox is bound to a "Customers" table Primary key, but I want to test the actual customer name (a the visible column in a combobox, not the bound number).

  4. #4
    MatthewGrace is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2013
    Posts
    159
    OMGoodness I think I have it...

    [cboCustomer].Column(1)

    Simple enough and seems to work.

    But I do wonder... why brackets? What purpose do they have? For a while I thought it was strictly to denote a field, now I see it can be a field or a control.

    This is especially burdensome because when you drop a bound control onto a form, Access gives them the same name, so you can't tell whether you're manipulating the Bound Field or the Control of the same name. Hmpf.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Yes, should be able to reference column by index (side note: query object cannot). Index begins with 0.

    [cboTestThis].[Column](1) = "Matthew"

    Yes, brackets denote an object (field, control, form, report, table, query, etc) as opposed to just a string of characters as defined by quotes or apostrophes.

    I always rename controls, like: tbxTest, cbxTest, lbxTest.
    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.

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    This is especially burdensome because when you drop a bound control onto a form, Access gives them the same name
    This is a fact of Access life. Worse, if you use a wizard to create a report or form, you get that for every control. So I deal with it by using the wizard to get a form in short order, but I go through every control and rename them right away. At the same time, Name Autocorrect is turned off. This will avoid any ambiguity on the Access side where it may not be able to distinguish between a field vs a control, plus you will never have to wonder what type of control you're dealing with when you look at code. Suggest you adopt a naming convention:
    http://access.mvps.org/access/general/gen0012.htm
    https://www.access-programmers.co.uk...d.php?t=225837

    What not to use in names
    - http://allenbrowne.com/AppIssueBadWord.html
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    MatthewGrace is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2013
    Posts
    159
    Micron, June... appreciate both your replies.

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

Similar Threads

  1. Replies: 4
    Last Post: 10-05-2021, 10:37 AM
  2. Replies: 2
    Last Post: 11-12-2015, 10:46 AM
  3. Replies: 5
    Last Post: 04-14-2014, 12:37 PM
  4. Just doesn't seem to work!
    By txmmoore in forum Reports
    Replies: 9
    Last Post: 01-16-2014, 11:39 AM
  5. Replies: 6
    Last Post: 05-26-2013, 09:10 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