Populating Labels

Posted by: kallumama on 4 August 2017, 2:45 pm EST

  • Posted 4 August 2017, 2:45 pm EST

    OK, i have a report where i have setup 10 labels in the PageHeader section. Now these headers will be populated from a grid. But depending on some other criteria not all the labels will be populated.

    The labels have been named lbl1, lbl2, lbl 3 so on till lbl10

    I am trying to write some code that will populate only certain labels.

    So is there a way to cycle through the labels and say like

    lbl & myCount = frmRev.TDBGrid1.Columns(myCount - 1).Caption

    Here myCount will be a number that will represent which column's data i am looking for. Like in the case above, i could have been populating lbl3 or lbl9 depending on what the myCount value was.

    So my question is how do i get the left part of the code to work...that is where i am having trouble....THANKS A BUNCH!!!!
  • Replied 4 August 2017, 2:45 pm EST

    In fact, that the porpouse of the fields: to get data from a DB, and the labels jus to display static text.

  • Replied 4 August 2017, 2:45 pm EST

    If you want to refer to a control through a string value, do so through the Controls collection.  For example:
    Me.Sections("PageHeader").Controls("lbl" & myCount).Caption = frmRev.TDBGrid1.Columns(myCount - 1).Caption

    I do not recommend retrieving the value in this manner however.  You should instead pass this external value to the report object through a public property, which stores this value as a member variable.  You can then just use:
    Me.Sections("PageHeader").Controls("lbl" & myCount).Caption = _myValue
  • Replied 4 August 2017, 2:45 pm EST

    Thanks, i got it working but still have problems with displaying data on the report as stated in my previous topic. If someone has any clue about it, please help me out.

  • Replied 4 August 2017, 2:45 pm EST

    can i use fields instead of labels to display column hearders in the PageHeader section?
  • Replied 4 August 2017, 2:45 pm EST

    Are you referring to another thread, or are you still having difficulty with something in this thread?
  • Replied 4 August 2017, 2:45 pm EST

    Thanks Peter, that was another issue but I got that sorted out!!

Need extra support?

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

Learn More

Forum Channels