How to Make the particular text field BOLD based on the Value from query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • balaryan
    New Member
    • Jul 2015
    • 3

    How to Make the particular text field BOLD based on the Value from query

    Hi All,

    Good day. I have a report which display the list of values (say 10 fields) from the basic SELECT * FROM table query.

    I need to dynamically set the BOLD based on the particular value for the fifth field which was assigned from Query. if it doesn't match it should display normal.

    E.g
    Code:
    If Field_5 = "Agent" then
    Field_5.FontBold = True
    Else
    Field_5.FontBold = False
    End if
    I tried the aforementioned code and it dont work. ALso i tried achieve it using below listed options.

    Code:
    Me.Field_5.FontBold = True
    Field_5.Properties("fontweight") = 700
    But nothing worked. Kindly assist me.
    Last edited by Rabbit; Jul 21 '15, 04:03 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • jforbes
    Recognized Expert Top Contributor
    • Aug 2014
    • 1107

    #2
    There are a few ways to do this. The way you are attempting to do it is one, and should work:
    Code:
    If Field_5 = "Agent" then
     Field_5.FontBold = True
     Else
     Field_5.FontBold = False
     End if
    My guess as to why it isn't is that the code is in the wrong place. It can be trying to find the right pace to put code in Access' Reports. I think you want you this code placed in the Detail_Format.


    An alternate way to do this that may appeal to you is to use Rich Text Format on the TextBox and then putting the formatting Inline in the Control Source. The added benefit is that all formatting is on the Design Surface of the Report. Here is an example of a ControlSource that combines two fields and Bolds the Labels:
    Code:
    ="<b>Customer:</b> " & [CustomerName] & IIf(Len([CustomerAKA])>0,"  <b>AKA:</b>","") & [CustomerAKA]
    It could easily be used to change bolding based on value:
    Code:
    =IIf([Field_5]="Agent","<b>" & [Field_5] & "</b>",[Field_5])

    Comment

    Working...