Alpha Video Training
Results 1 to 11 of 11

Thread: How to iterate through form controls

  1. #1
    Member
    Real Name
    TD. Lee
    Join Date
    Aug 2006
    Posts
    116

    Default How to iterate through form controls

    How would I go about iterating through the controls on a form to test if the background color of each control is a particular color?

    Thanks,
    TD

  2. #2
    Member
    Real Name
    TD. Lee
    Join Date
    Aug 2006
    Posts
    116

    Default Re: How to iterate through form controls

    Anyone???

  3. #3
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,300

    Default Re: How to iterate through form controls

    TD, there are probably several different ways to do this, but for the life of me I can't think why anyone would ever want to. What's the big picture?

  4. #4
    Member
    Real Name
    TD. Lee
    Join Date
    Aug 2006
    Posts
    116

    Default Re: How to iterate through form controls

    I have a form on which I set the color equation on certain fields to set the background color to canvas if the field is blank, white or the normal color, if it is not blank. This way I can visually tell the user which fields are required to be filled in.

    More importantly I can write a function to which I pass the form name as a parameter and have the function iterate throught the "Type in fields" on that form to determine if the background color is white or not; if not white then the function would return a logical value of false which I can use to throw up a message box telling the user there are fields that need to be filled in before saving the form.

    With this scheme I can use a single function with any form to test if the required fields have been filled in. Yes, I know you can set the fields to be required in field rules but I do not want/like the A5v7 message to appear.

    I am quite pleased with my scheme if I can find an example of code that shows how to iterate throught the controls, test to see if the control type is "Type in field" and then check for the background color.

    HTH,
    TD

  5. #5
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,300

    Default Re: How to iterate through form controls

    TD,

    Investigate <OBJECT>.CHILD_ENUM()

    I don't have experience using it but the help file discussion makes it look promising.

    Your concept is thought provoking. I haven't used color coding to distinguish required fields before and can see how that might be helpful. However, if most of your text controls are NOT required your approach will be checking and rechecking objects unnecessarily. The onInit script of your form could be used to populate an array of field names all of which are required. Your save record sequence could then check only the fields in the array and not have to iterate through the other fields where text is optional...

    Anyway, good luck with your project.

  6. #6
    Member
    Real Name
    TD. Lee
    Join Date
    Aug 2006
    Posts
    116

    Default Re: How to iterate through form controls

    Thanks Tom!

    TD

  7. #7
    Member
    Real Name
    TD. Lee
    Join Date
    Aug 2006
    Posts
    116

    Default Re: How to iterate through form controls

    My first attempt at creating a custom function in A5v7. It's purpose is described earlier in this thread. Can someone tell me what I'm doing wrong with this code?

    Thanks,
    TD

    FUNCTION req_fld_chk AS L (form_name AS P )
    Dim frm as P
    Dim lst as U

    frm = form_name
    lst = frm.Child_Enum("f=Type-in Field")
    *for_each(fld,iif(fld.fill.forecolor = "canvas",req_fld_chk = .t.,req_fld_chk = .f.),lst)

    END FUNCTION

  8. #8
    "Certified" Alphaholic
    Real Name
    Thomas Patten
    Join Date
    Apr 2000
    Location
    Duluth, MN
    Posts
    1,481

    Default Re: How to iterate through form controls

    I think Cal Locklin could help with this. website - www.aimsdc.net

    His array fixer works in this manner.

    Tom

  9. #9
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,595

    Default Re: How to iterate through form controls

    Bump!
    This was a recent link for its example. Did it ever get resolved and can we see what you did please? I like this idea for color coding the required fields and would like to know how it worked out.
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  10. #10
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: How to iterate through form controls

    Quote Originally Posted by MoGrace View Post
    Bump!
    This was a recent link for its example. Did it ever get resolved and can we see what you did please? I like this idea for color coding the required fields and would like to know how it worked out.
    TD's function appears to be trying to check the forecolor and if it is canvas, set the function's return value to true. The logical value would have been set according to the last type in object in the list. Is that what you want or do you want the reverse?

    IOW to set the forecolor to canvas for all required fields?

  11. #11
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,595

    Default Re: How to iterate through form controls

    Hi Stan,
    It was an interesting idea, I am not sure how I would use it. I noticed though that if I color the fields that when the cursor enters the field it changes to white. (Database settings). It would be good to have a filled in field stay white if it is not blank. I already color the font for my key fields and am not sure if I want to change that to this idea or not. The colored fields also seem like a good idea for when a new record is being added. The payroll program I am using does this now.
    Last edited by MoGrace; 04-01-2008 at 03:55 PM.
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

Similar Threads

  1. Comparing Controls in a Form
    By KeithW in forum Application Server Version 8
    Replies: 1
    Last Post: 06-05-2007, 10:47 AM
  2. Nested sorts/filters using form controls
    By seaken64 in forum Alpha Five Version 7
    Replies: 25
    Last Post: 05-19-2007, 10:28 PM
  3. Creating form controls dynamically
    By gcaplan in forum Alpha Five Version 6
    Replies: 11
    Last Post: 05-11-2005, 03:47 PM
  4. Add controls to a form on-the-fly
    By Sholom Hamada in forum Alpha Five Version 5
    Replies: 6
    Last Post: 08-30-2003, 09:33 PM
  5. Closing form with no controls.....
    By Jeff Klages in forum Alpha Five Version 4
    Replies: 2
    Last Post: 04-15-2002, 12:16 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •