By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,673 Members | 1,648 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,673 IT Pros & Developers. It's quick & easy.

Change colour of box within record of continuous form...

P: 50
Hi guys,

I have a continuous form and one field is Day / Night, where a 'D' or 'N' is contained to represent each.

Is it possible to write code for the 'on current' of the form to ensure a box contained within the specific record is one colour for those records with 'D' and another for those with 'N'?

I used for...each...next statement from the help and adapted it to suit my form, but it changed the colour of ALL of the boxes depending on which record was highlighted???

Hope you can help, OllyJ
Jan 29 '08 #1
Share this Question
Share on Google+
9 Replies


Expert 100+
P: 446
Hi again Olly
Have you tried 'Conditional Formatting' ? Highlight the control in design mode then click Format > Conditional Formatting. .

You will need Access 2000+. A young lady on this forum gave me the hint a few weeks ago but I haven't tried it yet.

I had previously done this using overlaid boxes which is OK to change colour of text within a box but not so for Background or Border, so the above method looks better.

Best of luck

S7
Jan 29 '08 #2

NeoPa
Expert Mod 15k+
P: 31,530
I explained this to someone the other day too.
Essentially Conditional Formatting is the route you need.

What you need to remember is that a control on a continuous form is simply the one control. When you make changes to the design, it's not to any specific instance of the control, but to the control itself.

There are reasons for this which you can think through if you consider how it would handle these if it were obliged to support the items separately. It would need to maintain an array of undefined size. Getting messy already.
Jan 29 '08 #3

P: 50
Thanks for your help so far guys...

I have applied conditional formatting to the textbox and the colours changed as desired. However, despite setting the properties of the textbox to enabled=false and locked=true, when running the form and clicking the mouse on the textbox it allows a text cursor to be placed inside... although it won't let you edit the text, it still causes a problem as it blocks out all of the textboxes in front of it.

Its as if when conditional formatting applies, it resets its default properties.

I have tried code 'on current' of the form to ensure that it stays enabled=false but this doesn't work...

Any ideas??

Hope you can help, OllyJ
Jan 30 '08 #4

Expert 100+
P: 446
Interesting . . .

I can't picture exactly what is going wrong for you (i.e. why the cursor in the box is a bad thing) but I understand that it should not be allowed there anyway.

I have not got first hand experience of this so will leave it to NeoPa . .

Until then I am guessing that Access is 'adding' overlaid boxes which are not picking-up the attributes you have set for your original text-box.


S7
Jan 30 '08 #5

NeoPa
Expert Mod 15k+
P: 31,530
I think you're trying to hide the TextBoxes conditionally. I'm afraid this is not supported. (Let me know if I have the wrong end of the stick here.)
Jan 31 '08 #6

P: 50
Sorry, probably my explanation, i'll have another go...

I have successfully implemented a method which allows me to highlight the current record within a continuous form when it is selected.

*** My problem is that the user needs to be able to click anywhere on any record to highlight it (make current), as I have all controls disabled (so they cannot be edited nor the cursor shown), it doesn't allow me to do this?
It does allow me if i have a control enabled but then auto' highlights the text of the control that is enabled (which is what i'm trying to avoid.) To reiterate... I could do with ALL controls and fields within my continuous form disabled but allow the user to highlight the current selected record without using the record selectors etc (just a click of the mouse anywhere on that record)

*** Also, prior to clicking the required record, I need for the mouseover event to be coded so that which ever record the mouse is over is highlighted. I have entered code for this 'onmousemove' but it highlights all records as soon as you move the mouse over one (being a continuous form). Any ideas??

Very specific requirements I know, I just have to deliver as many as possible!!

Many thanks in advance, OllyJ
Jan 31 '08 #7

Expert 100+
P: 446
Hi Olly

First problem first! It sounds like the built in Conditional Formatting will not do for you, so you will have to rely on the overlaid box technique.

Lets say you just want to change the colour of the text to start with. Lets say the field you want to display is called 'Field1' (I've exhausted my inventivness today) and you want the text to be Blue when Field1 =N and Red when Field1 = D

So, take you original box and copy then past it (so it should retain the same size) Now select one box and change the ForeColor to Red, and change the Control Source data
Expand|Select|Wrap|Line Numbers
  1.  =IIf([Field1]="D",[Field1],"")
Now select the second box and change its ForeColor to Blue, Set the Control Source to ;
Expand|Select|Wrap|Line Numbers
  1.  =IIf([Field1]="N",[Field1],"")
Oh, I did not say that the Background of these boxes should be Transparent, now if you set their Top values the same they should align and when you run the form you should get the effect you want.

As they are both transparent you should see your highlight bar through them. You may have to bring them to the 'front' (Format > Bring to Front)

I haven't found a way to change the Border colour but you can mess with the background by creating two more boxes, setting their ForeColour as required and using similar code, but instead of displaying the field name you display a series of block-box characters.

=IIf([Field1]="D","█████","")

These two boxes must obviously be set behind the text boxes!

If you use background colours for boxes then this will mess with the continuity of your highlight bar.

I think you have no hope with MouseOver in a continous form but I'll try something and get back.

S7

PS
The display in the forum has inserted "font=Arial" and "/font" in the above but these are not part of the code!

PPS
Then I took them out ;) -NeoPa.
Jan 31 '08 #8

NeoPa
Expert Mod 15k+
P: 31,530
I think an inherent problem with your requirements Olly, are that they must either be relative to the continuous items themselves (impossible as they are all instances of the one simple item), or they are relative to the basic form (making the task of overlaying very tricky to say the least).
Jan 31 '08 #9

Expert 100+
P: 446
Hi again Olly

I think there is very little chance of using OnMouseMove to move the highligt bar in a continuous form.

My highlight bars move by knowing which is the current record, then highlighting it. This means that the records can be scrolled with the mouse wheel then the user selects the required record by clicking. Alternatively, the up/down arrow keys or tab keys move between records so the highlight moves, to show the current record.

I imagine you could pick-up the co-ordinates of the mouse and draw a 'free-floating' highlight bar to match but what good would that do? If you take the mouse out of the continuous form, what is the highlight bar to do then?
S7
Jan 31 '08 #10

Post your reply

Sign in to post your reply or Sign up for a free account.