By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,998 Members | 2,921 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,998 IT Pros & Developers. It's quick & easy.

Change fontwieght of a field during On format event

P: 36
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!SupplierID) then
'Make all fields in this record bold
end if

I have tried :
Me!SupplierID.FontWieght = "Bold"
Me!SupplierID = Format(Me!SupplierID, "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

Jul 27 '07 #1
Share this Question
Share on Google+
4 Replies

Expert 100+
P: 114
Try this, it works for me.

Expand|Select|Wrap|Line Numbers
  1. Me.Fieldname.FontBold = True
Jul 27 '07 #2

Expert 2.5K+
P: 3,532
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:
Expand|Select|Wrap|Line Numbers
  1.  Private Sub Form_Current()
  2. For Each ctrl In Me.Controls
  3.   If TypeOf ctrl Is TextBox Then
  4.     If Not IsNull(Me!SupplierID) Then
  5.       ctrl.FontBold =True
  6.     Else
  7.       ctrl.FontBold = False
  8.     End If
  9.   End If
  10.   Next
  11. End Sub
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)>
Jul 27 '07 #3

P: 36
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 !!!!
Jul 28 '07 #4

P: 36
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.
Jul 29 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.