Conditional Formatting - Form Based On Text Box Entry

CarolW

Registered User.
Local time
Today, 08:59
Joined
Mar 24, 2006
Messages
58
Hello,
Could some kind person out there help me out please?
I have been 'dabbling in' the area of conditional formatting, particularly in the area of changing the colour of my active form based on the result of what’s output on a text box. I have had some success in this area but where I am getting confused is getting the colour of my form to change on the basis of what is entered into a text box control that does not match exactly. My forms background changes to the required colour when its value is ‘set exactly’ but what I am trying to achieve is to change it according to the first letter of entry regardless of what follows? It always starts with a letter, either a ‘D’ or ‘V’ to indicate whether its ‘Vital’ or ‘Desirable’ and is subsequently followed by no more than 6 numbers and finally a letter. Basically I need my form to change colour based on the whether it is either a ‘V’ or a ‘D’ irrespective of what follows???

What I have been using so far is:

Private Sub Model_Number_AfterUpdate()
If Me.Part_Number = "V111145K" Then
Me.Section(acDetail).BackColor = 12632256 'Light Red
Else
Me.Section(acDetail).BackColor = 8421631 'Blah Gray
End If
End Sub


Private Sub Form_Current()
If Me.Part_Number = "V111145K" Then
Me.Section(acDetail).BackColor = 12632256 'Light Red
Else
Me.Section(acDetail).BackColor = 8421631 'Blah Gray
End If
End Sub

Can anyone help me out of a ' sticky situation'..

Ta Very much

Carol
 
Have you tried: If Left(Me.Part_Number,1) = "V" Then

Please do not double post! At least Ken and I agree.
 
Last edited:
Thank you very much for your very prompt response. It worked an absolute treat....
Could you please advise me as to where I could gain further information on this very subject as I am new to this sort of thing and would like to 'broaden my horizons' so to speak!


Really appreciate your help

Carol:)
 
Hi Carol,
"This" subject is simply memorizing many of the functions in VBA. For me it just comes with time coding, and I personally have pleanty. The Left() function is a string handling function and just getting lost in the VBA help system looking at the examples and following the "See Also" suggestions might help. There are also a ton of books on the subject if you prefer that approach.
 

Users who are viewing this thread

Back
Top Bottom