Change 'Font' colour depending on condition

scouser - Liverpool were truly awful today - thet have not fired on all cylinders at all this season - Monsieur Houllier is in for a rough ride!....

Anyway, your two code snippets seem to conflict with each other. On one hand (Form_Current) you are setting the OrderClosed value according to the value of the TotalGross and OrderBalance.
On the other hand (OrderClosed_AfterUpdate), you are allowing the OrderClosed value to be changed manually (but then calling Form_Current changes it to whatever condition is met with If .TotalGross >= "0.00" And .OrderBalance <= "0.00" Then
Do you really want both? If so, do not call the Form_Current event, format the controls from your After_Update code. But bear in mind, the next time you visit that record, the value of OrderClosed will be set by the condition mentioned before! Food for thought?
 
Food for thought

Cheif torturer eh........
Yep Houllier is on borrowed time.......not one to jump on the bandwagon but results are the nature of the business for which he gets well rewarded (good or bad). Anybody that pays 10 million for Diouf and lets Robbie Fowler leave needs to be slapped with a wet fish!!

Now the code. Haven't got a clue!! Only wanted to change the font colour and now this thread is HUGE! Ha! on_current / afterUpdate...all greek to me. Had loads of help on the DB from a very good source. Before my latest meddling it all worked OK. I thought it would be simple to change the font colour but it is proving to be more hassle than its worth!!
Cheers for your thoughts......
Come on Emile......................
Phil.
 
Meddling is the fun bit and where you learn from mistakes. The Code bit is fun and frustrating to learn (a bit like watching the reds actually) Greek is OK as I believe they are the forefathers of the current Alphabet - so eventually it will evolve.
 
Fizzio said:
Greek is OK as I believe they are the forefathers of the current Alphabet - so eventually it will evolve.

Greek, in so far as the word alphabet, comes from the first two letters of the Greek alphabet (namely alpha and beta). The Greek alphabet, however, is 24 letters and is of Cyrillic nature (but not the same Cyrillic as the Russians would use as reformaions have changed that - St. Cyril will be turning in his grave). We, as a language stolen from many cultures such as the Romance languages, Turkish, Indian, amongst others, use the Latin alphabet. A huge number of Latin words do, however, originate from the original Greek although the way they look is definitely chalk and cheese. Latin also has 24 letters - U& V were considered the same; I and J were also. Hope that helps. :cool:
 
Taking into account all that has been said!

Guys I have modified the code as suggested (got rid of the on_current in main order form) but am not quite there, can you see the flaw? This is on the OrderClosed check box.

Code:
Private Sub OrderClosed_AfterUpdate()
Dim ctlControl As Control

DoCmd.Maximize

With Me
     If .OrderBalance <= "0.001" Then
          .OrderClosed = True
          .OrderStatus.ForeColor = 255
          For Each ctlControl In .Controls
               On Error Resume Next
               ctlControl.Locked = True
          Next
     .OrderClosed.Locked = False
     Else
     .OrderClosed = False
     .OrderStatus.ForeColor = 16711680
     For Each ctlControl In .Controls
          On Error Resume Next
          ctlControl.Locked = False
          Next
     End If

End With
End Sub

Right, after checking the box to close the order the 'Order Closed' font changes to RED in the control 'OrderStatus' on the main order form.
If I then navigate away from the form and back again it has returned to BLACK...........
Phil. :confused:
Oh to be a Gooner!!
 
Mile-O-Phile said:
Greek, in so far as the word alphabet ....
Thanks for that lesson Mile-O. You really are a haven for useless information - your family must be proud ;)
 
Scouser, you still need some code in the Form_Current event to format the controls on a per-record basis.
Code:
Private Sub Form_Current()
with me
if   .OrderClosed = True then
     .OrderStatus.ForeColor = 255
else
     .OrderStatus.ForeColor = 16711680
end if
end with
end sub
That should do it.
 
End

At last this thread can rest..............
Cheers Guys,
Phil.
 

Users who are viewing this thread

Back
Top Bottom