Tabular Form - change bgcolour of field for a particular rec

shogan@mila.ieshogan@mila.ie Member Posts: 113
Hi everyone,

Is it possible in a Tabular-Type form that the background colour for the "Status" field is green if a record has it set to "Open" and red if set to "Closed"? This is an Option field and I'd like to dynamically set it. It's just the field I need, not the entire record.

I notice that this is not possible in a Card-Type form, but I have been able to use a button on a Card-Type Form to set the FOREcolor of the Status field but does not seem to be a way of changing the BACKcolor.

I am developing this for a user in a tabular style (she's coming from a manual Excel system).

As a workaround, but I had also thought of using VISIBLE on two controls - red and green filled rectangle shapes, and making the BackTransparent property of the Status field well, transparent, and set the VISIBLE properties on the red and green rectangles accordingly directly behind the status field.

But I don't know how to make a Card-Type Form look like a tabular-Type Form.

I'd love to hear how others would do it?


Regards,
Stephen

Answers

  • SavatageSavatage Member Posts: 7,142
    What do you want changed?

    See Example pics - is this what you want?
    1. Sales Order Form
    2. Sales Order List Form
  • MBergerMBerger Member Posts: 413
    I'd take a different approach here : use a picturebox control in your tabelbox, with the sourceexpression set to "status" and a list of bitmaps in the "bitmaplist" property for the different colors you want. No code needed :)
  • shogan@mila.ieshogan@mila.ie Member Posts: 113
    Hi Harry,

    The List Form looks perfect - but is it possible to have that colour effect dynamic on an Option field?


    Regards,
    Stephen
  • SavatageSavatage Member Posts: 7,142
    For the list form it was a simple adding to the OnFormat Trigger of the Status field:
    OnFormat(VAR Text : Text[1024];)
    CASE Status OF
      Status::Open :
      CurrForm.Status.UPDATEFORECOLOR(4953600);
      Status::Released :
      CurrForm.Status.UPDATEFORECOLOR(255);
    END;
    

    I'm not sure i'm following about the option field?
  • shogan@mila.ieshogan@mila.ie Member Posts: 113
    Hi Harry,

    Sorry - allow me to explain:

    I have the Status field set up as an Option Field in the background table - 'Open' and 'Closed' are the options.

    I have put your code into the OnFormat trigger, but the following error appears when I attempt to run the report:
    The Dynamic Property 'ColorSet' cannot be changed in this context. You tried to change 'ColorSet' to  on the TextBox named 'Status'.
    The double-space is intentional, and nothing is between "to  on" in the second sentence.

    Basically I'd like to have the colour change between red and green immediately on updating this field in the form.



    I am going to have lots of questions Harry, as I am building up quite a complex form, so be prepared! As always, thanks for your help Harry - really appreciate it.

    Regards,
    Stephen
  • SavatageSavatage Member Posts: 7,142
    FYI: Status is the "Name" of my control. Yours might be <Control1000000185> for example. you can rename it to something more descriptive. and use that in the code
  • shogan@mila.ieshogan@mila.ie Member Posts: 113
    Hi Harry,

    Exported the object as .txt and found I had inserted code into the wrong field!

    Your solution worked perfectly, thank you.

    Regards,
    Stephen
Sign In or Register to comment.