Color in VBA

lmcc007

Registered User.
Local time
Today, 17:27
Joined
Nov 10, 2007
Messages
635
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 TextDark 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:

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 TextDark blue I was using.

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?
 
What's the number of the blue? If you go to the properties section for forecolor what number is there? Replace your "vbBlue" with that number. Without the quotes.
 
What's the number of the blue? If you go to the properties section for forecolor what number is there? Replace your "vbBlue" with that number. Without the quotes.

Nah, it says Text Dark.
 
I have never seen anything in access for TextDark, where did you get that from? Even when I google it I don't get anything that is relevant.
 
I have never seen anything in access for TextDark, where did you get that from? Even when I google it I don't get anything that is relevant.

Using Access 2007.

In Design View select the object, open Properties, go to Format, Forecolor, click the down around and choose Text Dark.
 
What are you using the Text Dark on? You can get the actual number for it by doing something like this:

If it is in the detail section of a form, for example, you can put a quick, temporary, double-click event in for the section and then use:

Code:
Debug.Print Me.Detail.BackColor

then in your Immediate Window you will have the color number you can copy and paste to match. Similar for whatever has the color you want.
 
What are you using the Text Dark on? You can get the actual number for it by doing something like this:

If it is in the detail section of a form, for example, you can put a quick, temporary, double-click event in for the section and then use:

Code:
Debug.Print Me.Detail.BackColor

then in your Immediate Window you will have the color number you can copy and paste to match. Similar for whatever has the color you want.

That's it. Wonderful! Thank you.
 

Users who are viewing this thread

Back
Top Bottom