VBA conditional formatting problem

Andy B

Registered User.
Local time
Today, 09:43
Joined
Oct 14, 2004
Messages
31
OK my problem is as follows,

I am using Access 2003 and i am running a form which already uses the 3 available conditional format options.

I have read on the forum about VBA conditional formatting and this didnt seem to be to bad.

However i have used the available code , but VBA is telling me it doesnt recoginse forecolor, nor indeed does it recongise backcolor either.

the code i was using was

Select Case Me.[stock in]
Case Is =-1
Me.[customer order no].forecolor = 255
End Select

Any thoughts would be much appreciated.

Andy B
 
I'm using the following code to format various textboxes when a form first opens. I know there are several ways to select colors. Here is a link to RGB colors http://www.seattlecentral.org/faculty/ymoh/mic110vb/color_chart.htm

Hope this helps. -Tom

Private Sub form_Open()

Select Case Me.[Status]
Case "Completed study"
Forms!mainsubform!Text59.BackColor = vbGreen
Case "Dropped from study"
Forms!mainsubform!Text59.BackColor = vbRed
Case "Rejected"
Forms!mainsubform!Text59.BackColor = 65535
Case Else
Forms!mainsubform!Text59.BackColor = RGB (255, 255, 255)
End Select
 
Vba Conditional Formatting Problem

Tommy,

Thanks for your reply, however I think I may have mislead you a bit. the problem is not the code for the colour but the actual word "forecolor" or "backcolor". VBA does not want to accept this as a known variable.

Hence my problem. I have read that these variables are not always "turned on" but the posting gave no clue as to how or where to do this and i cannot find it.

Andy B
 
forecolor is correct, you may have a broken reference which can cause some weird effects. in any module Tools>References... scan down the list of ticked libraries and see if any say 'missing' at the start. if so untick it and see what happens

HTH

Peter
 
Vba Conditional Formatting Problem

I think i have sorted out part of the problem, but this has left me with other problems.

After a bit of messing about i got the forecolor variable to work. Obviously when it wasn't letting me have this option it was because it did not think it appropriate.

So i think the question i should now be asking is as follows, my form shows customers, and within the form is a subform wihch shows orders for that customer. i already use the 3 conditional formatting options to colour code these orders to invoiced, samples & stock in, however i now have need of a forth option "call off" hence my need to do it through VBA.

When i have tried to run the code and link to current it will not show the colour change unless i select it at which point all orders go that colour.

I assume this is something to do with the fact that it is a subform.

Any ideas on a work around would be gratefully recieved
 

Users who are viewing this thread

Back
Top Bottom