Change fontwieght of a field during On format event

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • FNA access
    New Member
    • Jun 2007
    • 36

    Change fontwieght of a field during On format event

    I can't seem to be able to access the font weight property of a field.

    What I am doing is during the on format event of my form, If my key field is not blank or null then i want to make the whole record bold

    If Me!SupplierID <> "" And Not IsNull(Me!Suppl ierID) then
    'Make all fields in this record bold
    end if


    I have tried :
    Me!SupplierID.F ontWieght = "Bold"
    Me!SupplierID = Format(Me!Suppl ierID, "Bold")

    I have 8 fields in my record set so I would need to do this for each one

    I also tried to create a control type variable and loop through all controls in acdetail

    I would appreciate any input very much

    Thanks
  • damonreid
    Recognized Expert New Member
    • Jul 2007
    • 114

    #2
    Try this, it works for me.

    [code=vb]Me.Fieldname.Fo ntBold = True[/code]

    Comment

    • missinglinq
      Recognized Expert Specialist
      • Nov 2006
      • 3533

      #3
      Your post is a little confusing, as you speak of a Form and the OnFormat event. There is no OnFormat event for a Form, only for a Report!

      Assuming that you are speaking of a form, damonreid's suggestion is valid. It needs to be placed in the Form_Current event, and rather than set each textbox control to bold, you can simply loop thru all textboxes like this:
      [CODE=vb] Private Sub Form_Current()
      For Each ctrl In Me.Controls
      If TypeOf ctrl Is TextBox Then
      If Not IsNull(Me!Suppl ierID) Then
      ctrl.FontBold =True
      Else
      ctrl.FontBold = False
      End If
      End If
      Next
      End Sub[/CODE]Note that this will only work on a From in Single View; to do this kind of thing for a Continuous Form requires using Conditional Formatting. Also be aware that when working in Design View and changing thiskind of formatting, Access can be very tempermental. After making a this kind of change in code, you often have to close the form then re-open it. Simply making the change in code then, from Design View running the Form doesn't always show the new formatting. Occasionally you may even have to close the database then re-open it for the changes to take place.

      Good Luck!

      Linq ;0)>

      Comment

      • FNA access
        New Member
        • Jun 2007
        • 36

        #4
        Sorry about the confusion in my post. I am trying to code the on format event for a report. I will try .fontbold. I didn't know that was how to set the weight, nor could I find that information anywhere.

        I will respond with how it works. Thanks to all that replied !!!!

        Comment

        • FNA access
          New Member
          • Jun 2007
          • 36

          #5
          Thank you to all !!!

          It works great. I decided just to bold some key fields instead of the whole line. DamonReid's code works perfectly. Just used an if else to toggle between bold and normal during the OnFormat event of a Reports detail line.

          Comment

          Working...