469,332 Members | 6,650 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,332 developers. It's quick & easy.

Change the colour of a records font, based on value in field Multiple Item Forms

112 100+
I am trying to change the font colour of certain records in a Multiple Item Form based on what value is in a Combo-box. The code below works for a single record view form but not the multi. It will change all the records displayed to the colour of which ever record I am currently on. Is there a way of making it work so that only the records with the value I have set appear with the colour I have set?

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. '0 is for black
  3.     '255 is for red
  4.     '2337696 is dark yellow OnLoan
  6. If Forms!frmFormlist![CurrentLocationSite].Value = "Deaccessioned" Then
  7.         ChangeFontColor ("255")
  8.     Else
  9.         ChangeFontColor ("0")
  10.     End If
  12.     If Forms!frmFormlist![CurrentLocationSite].Value = "On Loan" Then
  13.         ChangeFontColor ("2337696")
  15.     End If
  16.  End Sub
Expand|Select|Wrap|Line Numbers
  1. Public Sub ChangeFontColor(color As String)
  2.     Forms!frmFormlist![txtAccNum].ForeColor = color
  3.     Forms!frmFormlist![ObjectName].ForeColor = color
  4.     Forms!frmFormlist![ObjectType].ForeColor = color
  5.     Forms!frmFormlist![CurrentLocationSite].ForeColor = color
  6.     Forms!frmFormlist![PermanentLocationSite].ForeColor = color
  7.     Forms!frmFormlist![Subject/Image].ForeColor = color
  8. End Sub
Mar 17 '11 #1
5 5473
2,321 Expert Mod 2GB

But you can use conditional formating to colour a single field on your continuos form. (or apply conditional formatting to all fields). However conditional formattign seems to be a bit sluggish when I have used it.
Mar 17 '11 #2
32,182 Expert Mod 16PB
Smiley's absolutely right about that. See Why Values in Unbound Form Controls Don't Persist for a fuller explanation.
Mar 20 '11 #3
112 100+
Thanks guys, has you have saved me time trying to figure how to do something that is not possible. Also Thanks NeoPa for the artical... I now understand why.
Mar 21 '11 #4
32,182 Expert Mod 16PB
Very pleased to hear it Redbeard :-)

Knowing to/not to do something is one thing. Understanding why is so much better.
Mar 21 '11 #5
904 Expert 512MB
What version of Access are you using? If using AC2007 above you may find this helpful.http://bytes.com/topic/access/insigh...imited-colours

Mar 21 '11 #6

Post your reply

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

Similar topics

1 post views Thread by amber | last post: by
2 posts views Thread by James X. Li | last post: by
4 posts views Thread by ACaunter | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.