How to display the dates selected in the form to a Datareport??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sivethu
    New Member
    • Mar 2008
    • 1

    How to display the dates selected in the form to a Datareport??

    Hi...
    Please help....
    I have 2 DTpickers.And when i submit the form ,i want to display the date selected from the DTpickers in the labels placed in the Data Report .Please help....

    Thanks in Advance.
    Sivethu.
  • VBWheaties
    New Member
    • Feb 2008
    • 145

    #2
    Enumerate each section to find your label controls.
    Each section has a controls collection.
    Enumerate the controls collection and catch any labels using TypeOf.
    When a label is found, check its .NAME property to determine what the .CAPTION property should be.

    Example:

    Code:
    Dim I As Integer
    Dim J As Integer 
    With MyDateReport
       For I = 0 to .Sections.Count - 1 'Report sections
          For J = 0 to .Sections(I).Controls.Count - 1  'Section controls
             If TypeOf (.Sections(I).Controls(J)) Is Label Then   'Look for Label control
                If .Sections(I).Controls(J).Name = "lblDateFrom" Then 
                   .Sections(I).Controls(J).Caption = "03/11/2008"
                ElseIf .Sections(I).Controls(J).Name = "lblDateTo" Then
                   .Sections(I).Controls(J).Caption = "03/12/2008" 
                End If 
              End If 
            Next J 
        Next I 
    End With

    Comment

    • pureenhanoi
      New Member
      • Mar 2007
      • 175

      #3
      Originally posted by VBWheaties
      Enumerate each section to find your label controls.
      Each section has a controls collection.
      Enumerate the controls collection and catch any labels using TypeOf.
      When a label is found, check its .NAME property to determine what the .CAPTION property should be.

      Example:

      Code:
      Dim I As Integer
      Dim J As Integer 
      With MyDateReport
         For I = 0 to .Sections.Count - 1 'Report sections
            For J = 0 to .Sections(I).Controls.Count - 1  'Section controls
               If TypeOf (.Sections(I).Controls(J)) Is Label Then   'Look for Label control
                  If .Sections(I).Controls(J).Name = "lblDateFrom" Then 
                     .Sections(I).Controls(J).Caption = "03/11/2008"
                  ElseIf .Sections(I).Controls(J).Name = "lblDateTo" Then
                     .Sections(I).Controls(J).Caption = "03/12/2008" 
                  End If 
                End If 
              Next J 
          Next I 
      End With
      There is a shorter way:
      Private Sub cmdPrint_Click( )
      myDateReport.Se ctions("Section Name").Controls ("ControlName") .Caption = Date
      End Sub

      When you design your report, you know exactly which Section you put the control. Do not need parse all Sections, and all Cotrols to find out the lblDate
      ;)

      Comment

      Working...