Full Version: Colour text
UtterAccess Forums > Microsoft® Access > Access Forms
scuzz
Hi guys,
On my appointment calendar, i would like to give my user the option to chose what colour font the appointments appear in.
Green = everyday normal lessons
Red = a test
Blue = anything not to do with the driving school e.g. watching football
Is it possible to make the default green (i can already do this bit) but have 3boxes which will change the colour of the current record, just like the ones displayed when we reply to a message on this board (beside the emotions link)
I think it would probably be possible to use a option group but i dont really have the space for that.
Thanks for any advice
Jack Cowley
I am not quite sure what you are after but take a look at Conditional Formatting. From there you can have the text color change based on a variety of things...
th,
Jack
ALaRiva
You'll need to store the value of the color as an attribute of that record.
o you could add another field say 'AppointmentColorType'
Then have 3 values, 1 for green, 2 for Red, and 3 for Blue.
Then you'll have to code, the change the .ForeColor Property of the Appointment itself based on this value.
HTH, Thanks
-Anthony
scuzz
Would it be possible to push a button to cycle through these colours when it was pressed. So that the text would change colour instantly when the button was pressed?
ALaRiva
Yes. I'll see if I can put something together for you when I get to my clients office.
Anthony
scuzz
Thanks very much, very good of you!
JVanKirk
How about a combobox that you could pick the color from and OnClick it change the fore color of the fields you want. I think the code would look something like:
e.Controlname.Forecolor = comboboxname.value
SSG VanKirk
scuzz
That sounds like a good idea too! I would prefer to use a button because that would be easier to use with a laptop trackpoint mouse, the user would just have to click on a larger area than a combo-box arrow selector. But if the button doesnt work then that would be a good alternative! thankyou for the suggestion.
JVanKirk
I recall seeing a post on how to create a button that would control the dropdown box, thus enabling a larger down arrow button. However, you still have to do some extra moving then. I know part of your problem was color coding, what about just creating a button to open a color picker form. You could create a very attractive, professional looking little modal form that has the available colors and then sets the underlying forms control forecolor to the chosen color and then closes the form.
Just some other approach ideas.
Jason
scuzz
Its definately worth keeping in mind incase the other option does not work. But seeing as there are only 3 colours, with one as the default, i think it may be a bit superflous.
JVanKirk
Superflous...hang on let me get the dictionary..HAHA OK...well maybe you could try this but I don't know if it would work, didn't try it.
On the OnClick event have something like
If Me.onecontrolname.forecolor = vbGreen Then
Me.Controlname.Forecolor = vbRed
Me.NextControlName.ForeColor = vbRed..so on
ElseIf Me.onecontrolname.forecolor = vbRed Then
Me.Controlname.Forecolor = vbBlue
Me.NextControlName.ForeColor = vbBlue..so on
ElseIf Me.onecontrolname.forecolor = vbBlue Then
Me.Controlname.Forecolor = vbGreen
Me.NextControlName.ForeColor = vbGreen..so on
EndIf
EndIf
EndIf
I think there is a way to change all the control with one line but I don't recall how.
Jason
ALaRiva
Here's a simplified version that might get you on track. It makes use of a table to store the various colors you can have, and looks them up through a function.
The main reason I would do it this way is for flexibility. You can easily add new colors, change the order of which they should cycle and such. Flexibilty being the key.
Have a look at that, and if you prefer not to use a table, then let me know and I can put together another approach.
HTH, Thanks
-Anthony
scuzz
Right i'll have a look later on, need to go and have my buttock severley wooped in a game of squash now! HAHA
ALaRiva
Why would you be wooping your buttock with a vegetable?
OFL, Sorry I had to . . .
JVanKirk
AL...I just got done doing the same in an inquiring mines (mistype I hope) that someone posted. Anyway, about thread. If you need flexibility I would definatly approach it another way than my previous post. If you KNOW you will NEVER need differant colors, the choice is yours what way to go about it. I think I would still have gone with a dropdown or a cool popup form.
ALaRiva
Jason,
The request isn't mine, but I definitely agree that if it's not going to change any, that you could easily just use a standard collection to hold all of the colors, but for flexibility, the method I suggest would be best, IMHO.
I do agree that a dropdown or popup would be a little nicer for setting the color though, but as the original poster mentioned, most of the users are on laptops so ease of use is key.
Thanks
-Anthony
scuzz
Both of you have valid points. The ease of use is important to me, but the range of colours will be fixed. Only three of them are needed. Im not sure who's suggestion to go for!
.S. buttocks are not wooped, i managed to win!
scuzz
Hi there,
LaRiva, i've had a look at your example and it does what i want. I looked in the table expecting to see a number defining the colour, but was confronted with something else. How would i find out what code corresponds to the colours i would like to pick? Also, i looked in the code window under general, and saw some stuff which i wasnt too familiar with. Im not sure what:
CODE
Public Function getColor(pColor As Integer) As String
    
    Dim cnn As ADODB.Connection
    Dim rs As ADODB.Recordset
        Set cnn = CurrentProject.Connection
        Set rs = New ADODB.Recordset
        
        rs.Open "SELECT * FROM tblPriorityList WHERE ([PriorityID]=" & pColor & ");", cnn, adOpenKeyset, adLockReadOnly
        
            If rs.EOF And rs.BOF Then
                'If the passed value isn't found, return the default green
                getColor = "&H00FF00"
                    Else
                getColor = rs!PriorityColor
            End If
        
        rs.Close
        
        Set rs = Nothing
        Set cnn = Nothing
End Function

is meant to do. Bearing in mind that this code will be inserted into a subform, and then these records will be printed on a report. Will it cause anyproblems?
scuzz
I do understand most of it, just not the .connection part. why do i need a connection?
ALaRiva
The connection is so that ADO knows which database to use when looking up the colors in the table. This is required because ADO can connect to outside sources other than Access (i.e. SQL Server, XML, etc.)
But if you notice, I just used CurrentProject.Connection to refer to the current database.
-Anthony
scuzz
I see. well how do i choose the colours that i would like. Is there a table somewhere that i can look up?
ALaRiva
Sure. I used Hex Color Values for it, so you can go to this site - http://www.ficml.org/jemimap/style/color/wheel.html
And then find the color you want. It'll be in the format of a # and six characters following. When you put the color into the Table, you are going to put '&H' (no quotes) and the six characters. No '#'
Give that a go and let me know if you need more help.
HTH
-Anthony
scuzz
Thanks i'll give a go tomorrow (its getting late over the pond)! Im still having major problems with the Nz post, would you mind taking a look?
link
Thanks very much
ALaRiva
You're Welcome . . . frown.gif
et me know if you have any more problems with it.
-Anthony
scuzz
Hi there ALaRiva,
I've tried transferring your code into my project and i think i've just about got it done. It now changes the colour of the text, but on my form it changes all the records (its a continous form) but i've set the control source, so i dont know why its changing all the records instead of just the one im trying to modify.
ALaRiva
If you're using a Continuous Form then you'll have to use Conditional Formatting.
If you zip up and attach a copy of the database (without any 'real' data) I can give it a whirl for you to still work similar to what I've given you.
HTH, Thanks.
-Anthony
scuzz
Thats very kind of you ALaRiva, but i dont think i'll bother with it now. My end user didnt seem that bothered when i told him i was having difficulty changing the colours. Perhaps i'll just add a field which says Test or something to the report so that it stands out a bit! Thanks again!
JVanKirk
Scuzz..don't give up on it, colors are the fastest way to get attention to something that needs to stand out...well, that and motion.
Why don't you post a stripped version(just what is needed to work with) so Al or myself can take a look at it and come up with some feasible ideas for you.
Jason
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.