How to loop through field names

Posted by: grichg on 4 August 2017, 2:43 pm EST

  • Posted 4 August 2017, 2:43 pm EST

    We are trying to add a report to an old program.  In this report we have defined fields "Field1" through "Field50" and "Field51" through "Field100" directly into the ActivexDesigner.
    We would like to be able to loop through the fields 1 - 50 programmatically everytime the report reaches the detail section and change fields 51 - 100.
    I cannot find a way to address each one in, for example:

    for x=1 to 50
       set fld = "Field" & cstr(x)
       if fld.value = varY 
           set fld = "Field" & cstr(x+50)
           fld.value = varW
           x=50
       endif
    next x

    Is there some way to address each one like this?
  • Replied 4 August 2017, 2:43 pm EST

    To access textbox fields within a section, use its Controls collection.  Please see the following KB article:
    http://www.datadynamics.com/ShowPost.aspx?PostID=106
  • Replied 4 August 2017, 2:43 pm EST

    Hi Peter
    That may do what I need.  I really need to relate, for example, Field16 to Field56.  There is an offset of 50.
    So I'm going to try going for a substring of the name as in "xxx = val(mid(sec.Controls(y).Name,6))"  and then try to place a value as in "sec.Controls(xxx).DataValue = varY"

    Thank you for the tip

    Rich G.
  • Replied 4 August 2017, 2:43 pm EST

    You're welcome.  Let me know if you have any followup questions regarding this isuse.
  • Replied 4 August 2017, 2:43 pm EST

    Peter
    A variation of the tip worked great.
    It did what I needed.
    Rich
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels