Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

change form background colour

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    change form background colour

    I have set up a 'rolodex' name and address file. Nothing fancy. I want to be able to make the form background white for 'cash' customers and blue for 'credit' customers.I know I have to set up a field/variable being cash or credit. But how do I incorporate this into automatically changing the form background dependent on the field contents?

    Thanks in anticipation

    Jeremy Packman

    #2
    RE: change form background colour

    Put some code in the OnFetch event of the form. I don't know the syntax off the top of my head, but something to the effect of:

    If Customer.value = "Cash"
    this.background = "white"
    Else if Customer.value = "Credit"
    this.background = "blue"
    end if

    Assuming that the Customer Field OBJECT name is "Customer".
    In the code editor look at the Xbasic Explore objects/windows/your form name/properties/...
    Peter
    AlphaBase Solutions, LLC

    [email protected]
    https://www.alphabasesolutions.com


    Comment


      #3
      RE: change form background colour

      Oh yeah. You might have to end the script with:

      this.refresh()

      It may or may not be necessary.
      Peter
      AlphaBase Solutions, LLC

      [email protected]
      https://www.alphabasesolutions.com


      Comment


        #4
        RE: change form background colour

        Thanks Peter
        I tried it and if I did it right, I got an 'Action Program Error' when going into the form. It said:
        Trapped error in action command:(1)
        Command: Inline Xbasic
        Error: Object does not support requested interface.

        followed by Abort/Retry/Ignore


        Any suggestions????

        Jeremy

        Comment


          #5
          RE: change form background colour

          Instead of this.background = "white" try

          parentform.fill.forecolor = "white"

          Worked for me on a test form and parentform will make it portable for any form regardless of name.

          Jerry

          Comment


            #6
            RE: change form background colour

            I've tried all the above, but still get error message when entering the form saying:
            Action Program Error
            Trapped error in action command(1)
            Command:inlinebasic
            Error: Object does not support requested interface.

            Can someone explain what this means and perhaps talk me through what I need to do step-by-step from the beginning.I presume it is a form object..onfetch command I need. Maybe i'm not creating the xbasic properly since i copied the script lines exactly and checked for accuracy.

            Your help would be much appreciated.

            Jeremy

            Comment


              #7
              RE: change form background colour

              In the form's onSave() event I use
              :Ords_Rapid_Field_Results.fill.forecolor = "DARK RED"
              to let the user know not to do anything while the computer is running a large script, and
              :Ords_Rapid_Field_Results.fill.forecolor = "DARK BLUE"
              to let the user know it's ok to continue (usually just flashes on fast systems).

              Using the form (or other object's) name with the command it always works (until you save the form with a different name). For some reason I've always had problems using "this" and parentform" commands. I found that explicitly naming the object works. Since A5 puts underscores where there are spaces between parts of an object's name, (and since I forget syntax once in a while) I try to use A5's Xbasic Explorer.

              On the menu bar in the code editor there is a little wrench. If you click this you get a box to select various things from. Select
              Objects
              Windows
              (whatever your form's name is)
              Properties
              Fill
              and then highlight Forecolor
              Click/drag forecolor to your script and release the mouse button where you want it. A5 will fill out the entire command, you just add specifics such as color. One thing to watch is to make sure you don't release the dragged method or property in the middle of another xbasic statement. It can get a little messy if you do. I always release it in a blank line.

              Comment


                #8
                RE: change form background colour

                Thanks I'll give it a go. However will it work with what i want, which is to have the form show one of two different background colours for each record, depending on the content of a field. In other words if field 'PAYMENT_TYPE' shows CASH, then the background would be white, but if in another record the field was entered as CREDIT, the background of the form would be blue.

                Thanks in anticipation

                Jeremy

                Comment


                  #9
                  RE: change form background colour

                  Jeremy
                  I have attached a little test app that has a form that does what you want. The table has one table, payment.dbf, with one field, payments. There are a number of test records with either Cash or Credit as the saved value. There is one form. I placed a small script on the OnFetch event

                  tbl = table.current()
                  if alltrim(tbl.payment) = "Credit"
                  parentform.fill.forecolor = "Blue"
                  else
                  parentform.fill.forecolor = "white"
                  end if

                  This script changes the background color based on the fetched value of the field payments. Incidentally, I usually use xbasic scripting for simple scripts rather than action scripting.

                  Jerry

                  Comment


                    #10
                    RE: change form background colour

                    Jim
                    I agree that expressly stating the form name is more stable than using "this" and "parentform", but I am lazy and like to create one script for many forms and operations. I avoid using the "this" reference as I never seem to know what has focus, but "parentform" usually worked ok except in cases where there are subforms and similar complications. I have had good luck using "topparent" in some cases.

                    On perculiarity, "parentform" and "topparent" don't seem to work reliably in action scripting and inline xbasic, but never seem to give problems in a straight xbasic script. Since I use xbasic most of the time, I haven't had many problems.

                    Jerry

                    Comment


                      #11
                      RE: change form background colour

                      Thanks Jerry and Jim, its much appreciated

                      Jerry

                      Comment


                        #12
                        RE: change form background colour

                        And of course not forgetting Peter who originally replied to my problem. Thanks to you all

                        Jeremy/Jerry

                        Comment


                          #13
                          RE: change form background colour

                          Jerry
                          Your formcolorscript.zip worked a treat. But I want my form to have a tabbed object on it so that all of the tabbed pages as well as the main form background will be white or blue depending on the contents of the field.
                          What extra do I have to do to achieve this? I've played around a bit with your script but can't seem to do it, the tabed pages stick to being grey regardless!!

                          Thanks in anticipation

                          Jeremy

                          Comment


                            #14
                            RE: change form background colour

                            Jerry
                            Your formcolor.zip worked a treat. But I want my form to have a tabbed object on it so that all of the tabbed pages as well as the main form background will be white or blue depending on the contents of the field.
                            What extra do I have to do to achieve this? I've played around a bit with your script but can't seem to do it, the tabed pages stick to being grey regardless!!

                            Thanks in anticipation

                            Jeremy

                            Comment

                            Working...
                            X