Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Halpp ! Form conditional formatting.....

Status
Not open for further replies.

CSHANKY

IS-IT--Management
Jun 4, 2003
20
US
I have a simple problem - but my career sort of depends on it.

1. I have a database with Table1 with fields Yes/No1, Text1, Text2, Text3, which appear on Form1.

How do I make the fields Text1, Text2, Text3 boxes appear shaded light-blue when Yes/No1 is "yes" ?


2. I have a database with Table2 with fields Text1, Text2, Text3, Text4 which appear on Form2.

How do I make the fonts of Text2, Text3, Text4 appear:

a. Red when Text1 contains text 1-EU
b. Blue when Text1 contains text 2-US
c. Green when Text1 contains text 3-PAI


Could someone provide me the sample code or explain ? I am not a programmer hence this has become a big stumbling block. If I can't get this problem fixed my demo will fail and the repurcussions could be....


Thanks and Happy Holidays !
 
For the first one, it sounds like what you want is Enabled, not shaded. It sounds like you only want information in those boxes IF Yes/No1 = Yes correct? It is better to use the Enabled property of each text box. That way, if the box is set to "No", then they can not type anything.

In the Form's On_Current property, select Event procedure, then press the box with "..." to the right. Paste the following.

If Me.Yes/No1.Value = 1 Then
Me.Text1.Enabled = True
Me.Text2.Enabled = True
Me.Text3.Enabled = True
ElseIf Me.Yes/No1.Value = 2 Then
Me.Text1.Enabled = False
Me.Text2.Enabled = False
Me.Text3.Enabled = False
End If

With this, when the form opens, if Yes is selected, it enables those fields. If No is selected, they stay disabled. This is for when you open an existing record.


Then, in Design view, select Yes/No1, go to the After_Update property, select Event Procedure, then "..." and paste this:

If Me.Yes/No1.Value = 1 Then
Me.Text1.Enabled = True
Me.Text2.Enabled = True
Me.Text3.Enabled = True
Me.Text1.SetFocus
ElseIf Me.Yes/no1.Value = 2 Then
Me.Text1.Value = Null
Me.Text2.Value = Null
Me.Text3.Value = Null
Me.Text1.Enabled = False
Me.Text2.Enabled = False
Me.Text3.Enabled = False
End If

This will enable the boxes and put the cursor in the first one when Yes, and EMPTY the boxes and disable them if No. That way if they select Yes, enter something, then decide it should be No and de-select the box, the values entered into the textboxes will be erased.

Hope that helps. Sean.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top