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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically Render Report Column Headings

Status
Not open for further replies.

pjd218

Technical User
Apr 14, 2008
40
US
Any suggestions on how to dynamically render report column headings based on a field value?

For example, I may have a machine with Items A,B,C. A daily sales ledger reports on item sales and volumes. The info for the report comes from a query based on a couple of crosstabs. The products can change.

I would need to string a portion of the query field name for the report column heading.

Any guidance is appreciated.

 
All report headings in an Access report are simply labels in the column heading section.

What you need to do is to change the caption of those labels in the format event of that particular (group level) section, according to the value of the "Product Name" fields.

Hope this helps.

Seaport
 
G'day pjd,

This should really be in the Access Reports forum are but I've no idea how to request it to be moved! The code below could be a starting point for you. Create 10 captions of "doesn't matter" on a report named txtCaption1, txtCaption2, ..., txtCaption10

Code:
Private Sub Report_Open(Cancel As Integer)
    Dim intCounter As Integer
    Dim ctl As Control
    Dim rpt As Report
    Dim strCaption As String

    
    Set rpt = Reports(Me.Name)

    strCaption="Test"

    For intCounter = 1 To 10         
        Set ctl = rpt("txtCaption" & CStr(intCounter))
        ctl.Caption = strCaption & cstr(intCounter) 
    Next intCounter
end sub

Good luck,

JB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top