ibiubu Posted March 31, 2002 Posted March 31, 2002 I have a calculation that is looking at the day from a date field. For example if the date field contains "March 1, 2002" Case(Day(FieldDate)=1,?,"") ? would be the result. In this case I want it to look at the field called "FieldDate" and if the day =1, I want it to change to color of a second field called "Today." Anyone know what code I would use in the place of the ? to acomplish this? also, can the same method me applied to making a field visible or hidden? [ March 31, 2002, 12:28 PM: Message edited by: Larry Ross ]
kraftyman Posted March 31, 2002 Posted March 31, 2002 short answer = not in windows (don't own a MAC) This is one of the things I love about MSAccess... Filemaker is not able to modify screen object properties by a script. There is workaround, involving creating a formatted calculation field which might have a different font and font colour. Then, depending on the information in your data field, this would either be a blank or have a displayed value. Of course, this only caters for one type of condition. You would need several such calculation fields to cater for each possible value you wish to trap for. Alternatively, you can redirect the user to another layout with appropriate format/colour combination. These method work, but it's no really satisfactory. It is like having your steering wheel locked in one position so you can only turn right, and then having to buy another car so you can turn left, and another to go straight ahead... you get the drift.
RussBaker Posted April 1, 2002 Posted April 1, 2002 You already have a date field called "FieldDate" and another field called "Today". Create 2 more fields called: code: TodayRed = if(Day(FieldDate)=1,Today,"") TodayBlue = if(Day(FieldDate)=1,"",Today) Format TodayRed as red text and TodayBlue as blue text. Make both fields transparent and superimpose them. Now, if the day component of FieldDate is 1, you will see red contents, otherwise blue contents. This sort of technique is useful in lists to highlight particular items. For example, you might want to have all costs over $1,000 show up as red or bills overdue show up as Orange, etc. Russ Baker
ibiubu Posted April 1, 2002 Author Posted April 1, 2002 This works great for controlling the color of the contents based on two variables. Is there a way for it to do the same for the field color itself. I hear there is no way to control the color of a field with a calculation. For example, if the results of the calculation is positive, the field is highlighted yellow, if the results are negative, the field stays the default color of white. I know this is possible, I have a sample calendar file that does this. I have looked at the calculation and just cand figure out how they did it. [ March 31, 2002, 06:55 PM: Message edited by: Larry Ross ]
RussBaker Posted April 1, 2002 Posted April 1, 2002 To get a background colour, its a very similar approach. For this you need a container field behind a transparent field containing your data. You also need 2 global container fields, one filled with Yellow and the other White. Now, the calculation for your background container field is along the lines of code: Background_Field = if(Number>0, g_Container Yellow,g_Container White) In formatting the Background_Field, make sure the graphic is set to reduce or enlarge to fill the field, and that proportions are NOT maintained. Russ Baker
Rigsby Posted April 1, 2002 Posted April 1, 2002 Here’s a quick way to change the background colour of a date field, depending on the day of the week: Create a global container field, repeating 7 times. (ColorStore) Drop this onto a layout somewhere, and then past a coloured rectangle into each field. I did this simply by drawing in FMP, copying, going into brows mode, pasting, then layout mode, change the colour, etc. etc. until you have 7 fields each containing a colour. Now create a calculating field, container, not repeating with the following calculation (presuming your date field is called Date1) Case( DayofWeek(Date1) <> "", GetRepetition( ColorStore, DayofWeek( Date1))) Now in your layout, set Date1 to transparent and ColorStore to not allow entry. Put colorStore behind Date1 and now when you change the date, the background colour will change with it. Normally I always advise to stay away from repeating fields, but for storing graphics or array type information they are perfect. Hope this helps. Rigsby PS. If you have problems with this, let me know and I’ll send you my demo file.
kraftyman Posted April 1, 2002 Posted April 1, 2002 Originally posted by Rigsby: Create a global container field, repeating 7 times. (ColorStore) Now create a calculating field, container, not repeating with the following calculation (presuming your date field is called Date1) Case( DayofWeek(Date1) <> "", GetRepetition( ColorStore, DayofWeek( Date1))) Now in your layout, set Date1 to transparent and ColorStore to not allow entry. Put colorStore behind Date1 and now when you change the date, the background colour will change with it. Such a simple request for Filemaker Inc to get to grips with isn't it? The lack of event handling is a real pain in the neck. The above solution is fantastic, but from a fundamentally simple request, we have been forced into a global container field, repeating seven times as well as a calculating field. Now multiply this by the number of fields required to have changing colour and see what happens to the performance with 1 million records. Congratulations to Rigsby for ingenuity, and a big raspberry to FM inc for making us drive from Melbourne to Sydney via Perth. ( sorry, local joke: it's an 8000km detour on a 1000km drive)
ibiubu Posted April 2, 2002 Author Posted April 2, 2002 OK, with some of the suggestions here is what I came up with. The file is basically a test file for something I will be working on on a bigger scale. The main layout is for entering task names with start /finish dates and description. The Print Report layout will print out a 30 day chart graphically representing the task list. This layout also automatically highlights todays date, and has buttons for scrolling through days, months and years. .sea file for MAC users http://63.226.105.147/ftp/guest/Chart.fp5.sea .zip file for PC users http://63.226.105.147/ftp/guest/Chart.fp5.zip LR
Recommended Posts
This topic is 8342 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now