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

Using VBA color

Status
Not open for further replies.

lmcc007

Technical User
May 7, 2009
164
US
I have a button called cmdImage. Caption = "Attachment" and ForeColor = TextDark.

I want it to display "No Attachment" in red when empty, and "Attachment" in Text Dark when it's not. That way, I will not have to click on the button to see if there are any attachments.

I created the following code:

If IsNull(DLookup("EventAttachment", "Event", "CompanyID = " & Me.txtCompanyID)) Then
Me.cmdImage.Caption = "No Attachment"
Me.cmdImage.ForeColor = vbRed
Else
Me.cmdImage.Caption = "Attachment"
Me.cmdImage.ForeColor = vbBlue
End If

The problem is: vbBlue is not the Text Dark blue I was using.

I tried: Me.cmdImage.ForeColor = RGB(0, 0, 100)

but it is just not the same color as the Text Dark.

How do I get it to leave the default values or to put the correct color blue back?

Or, should the above code be written differently?
 
Thanks dhookom,

I got it by using txtCompanyName field--that is:

Debug.Print Me.txtCompanyName.ForeColor
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top