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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bold and/or set color to false part of IIF statement

Status
Not open for further replies.

Hillary

Programmer
Feb 15, 2002
377
US
Is it possible to format the false part of an IIF statment differently then the true part?

Thanks for you help.

Hillary
 
Hi, something like this for an If Statement:

If Me.Text0 = 1 Then
Me.Text0.FontBold = True And Me.Text0.ForeColor = 255
Else
Me.Text0.FontBold = False And Me.Text0.ForeColor = 0
End If


It's easy with a select case statement:

Select Case me.txtCtrl
Case is = YourValue
me.txtctrl.ForeColor = 255 'red
me.txtctrl.FontBold = True

Case Else:
me.txtctrl.forecolor = 0 'black
me.txtctrl.FontBold = False
End Select

Hope that helps.
 
Next time, could you post an example, of what you meen? Code = results

pdldavis example is about changing the look of a field Color, Bold, Underline etc...

But your question can also be about using the Format Propery

For Example

Text1 = IIF (len(me.PhoneNum) < 7, Format(&quot;me.PhoneNum&quot;,&quot;(000) 000-0000&quot;), Format(&quot;me.PhoneNum&quot;,&quot; 000-0000&quot;))

Which would Change the Number 5551234567 to (555) 123-4567
Or if the number is 1234567 it would change it to 123-4567


Pierre
 
The formula is...

Business Case: IIf([Main Data.Expedite]=-1,&quot;No Business Case!&quot;,IIf([Status]=&quot;Business Case Rejected&quot;,[Status],&quot;Business Case Proposal&quot;))

If the result is &quot;Business Case Rejected&quot; I would like the text bold and the ForeColor red.

Thanks for your help.

Hillary
 
Assuming the name of your field you want to change the color is Status

This code is the same as mentioned by &quot;pdldavis&quot; except I using an IF statement and Your variables
Enter this code in you form module

Private Sub Status_LostFocus()

If Me.Status = &quot;Business Case Rejected&quot; Then
Me.Status.ForeColor = 255 ' Red
Me.Status.FontBold = True ' Bold Text
Else
Me.Status.ForeColor = 0 'Black
Me.Status.FontBold = False ' Normal Text
End If
End Sub


Pierre
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top