473,379 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

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

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
9 7077
sierra7
446 Expert 256MB
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
32,556 Expert Mod 16PB
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
OllyJ
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
sierra7
446 Expert 256MB
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
32,556 Expert Mod 16PB
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
OllyJ
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
sierra7
446 Expert 256MB
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
32,556 Expert Mod 16PB
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
sierra7
446 Expert 256MB
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

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

Similar topics

3
by: Peter Williams | last post by:
Hi All, I want to write some javascript for a html page which does the following. Imagine that the page contains a table with 2 columns and 3 rows, e.g.: +---+---+ | A | B | +---+---+
3
by: Hans Karman | last post by:
Is there any way in which I can have the background colour of one or more records set to the colour stored in a datafield within the record? Hans Karman, Canberra, Australia
3
by: Hans Karman | last post by:
Is it possible to set the background colour for each record in a continuous form to the colour stored in a datafield within that record? Hans Karman, Canberra, Australia
4
by: vidiot | last post by:
I am trying to create a subform that will display images related to the parent form. The subform is a continuous form as there will be several images that relate to the parent form. I checked...
3
by: ApexData | last post by:
I am using a continuous form for display purposes. Above this form, a single record is displayed so that when the user presses my NewButton they can enter a NewRecord which gets added to the...
10
by: webgirl | last post by:
Hi there, I've been searching the net & the forums here over the last few days for help with my problem & am getting myself really confused.. hoping someone may be able to help me here. I've...
2
by: aldeb | last post by:
My dilemma is as follows. I have a continous form that I am using as a Visual Display Form to show the status of records (SoeCodes). What their status currently is and what they have been. I have 6...
15
by: OllyJ | last post by:
Hi guys, probably a basic question but have been struggling for some time so thought i'd see if you could help. I have a main schedule table which contains the fields... Date; Machine; Arm/Head;...
2
by: OllyJ | last post by:
Hi guys hope you can help... ...do you have any idea how you can set a control's (within a single record in a continuous form) property to visible=false depending on the outcome of an update...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.