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!

Changing text box backgrond colour with function

Status
Not open for further replies.

cb9002

IS-IT--Management
Sep 2, 2008
17
GB
Good morning! I am using Access 2003.

I have written a function called ChangeColour that returns either vbRed, vbYellow or vbGreen. My code is:

Code:
Dim x as String

If Not (IsNull(comboProbability.value) Or IsNull(comboImpact.Value)) Then
    x = modBgrndColour.ChangeColour(comboProbability.value, comboImpact.Value)

    Debug.Print x

    Me.txtTitle.BackColor = x

End if

Debug.Print x returns the appropriate string, however trying to set the colour returns a type mismatch.

Any help would be appreciated, thanks.
 
I have also tried parsing the value within quotes e.g.

Code:
Me.txtTitle.BackColor = "" & x & ""
 
The function should return the constant value, not the constant name !

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How are ya cb9002 . . .

[blue]Back Color[/blue] data type is a [blue]Long Integer![/blue] (not text). You'll have to post the function [blue]ChangeColour()[/blue] so we can have a look . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Instead of returning a string have your function return these long int values:
vbred: 255
vbyellow: 65535
vbBlue:16711680
vbGreen: 65280
 
Sorted - function now returns the integers from MajP

Thank you all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top