Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Report Name to Function

Status
Not open for further replies.

kentover

MIS
Aug 21, 2002
41
US
I have a report with 3 subreports that will include a report header with 12 labels that dynamically change their caption. The month names will go into the labels relative to the current date.

The problem is that either the header or the function will not accept the report name in any format that I have tried. I have also tried changing the type to object etc... Also I have tried each naming method that I could find online and in the help docs. Here is the general code.


Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
TmLnHeaders (Report_subrptWorkplanIT)
end sub

Public Function TmLnHeaders(rpt As Report)
'Misc code
end function


Thank you for your help.
 
Would this work?

Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
TmLnHeaders ("Report_subrptWorkplanIT")
end sub

Public Function TmLnHeaders(rpt As String)

Reports(rpt).report
'Misc code
end function
 
I think that I am closer but it still does not like the report name. Do you think that it is possible that I am getting the error because function is referencing labels in the report header on format, leaving the function to think that the report is not open?
 
I didn't have any problems communicating with the report from a procedure placed in a standard module:
Code:
Public Sub FormatLabels(ByVal strReport As String)
  Dim rpt As Report
  
  Set rpt = Reports(strReport)
  With rpt
    .Section(1).Controls("lblTest1").Caption = DateAdd("m", 1, Date)
  End With
  
End Sub
...and here's how I called it from the report:
Code:
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
  FormatLabels Me.Name
End Sub

VBSlammer
redinvader3walking.gif

[sleeping]Unemployed in Houston, Texas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top