Posted 4 August 2017, 3:18 pm EST
If you want to add X number of fields at run-time to your report, you should use something like this:
Dim rptMain as ActiveReport1
Dim oCtrl as Object
Set rptMain = New ActiveReport1
'Set the datasource for your report
Set oCtrl = rptMain.Sections(“Detail”).Controls.Add(“DDActiveReports2.DataControl”)
oCtrl.ConnectionString = YourConnectionString
oCtrl.Recordset = YourRecordSet
'Set up Sections for your report
'set up group header
rptMain.Sections.Add “Group”, 1, ddSTGroupHeader, 400
rptMain.Sections.Add “foot”, 3, ddSTGroupFooter, 500
rptMain.Sections(“Group”).Visible = True
rptMain.Sections(“Group”).GrpKeepTogether = True
rptMain.Sections(“Group”).KeepTogether = True
rptMain.Sections(“Group”).BackStyle = 0
rptMain.Sections(“Group”).Repeat = 1
rptMain.Sections(“Group”).CanGrow = True
'set up group footer
rptMain.Sections(“foot”).Visible = True
rptMain.Sections(“foot”).BackStyle = 0
rptMain.Sections(“foot”).KeepTogether = True
rptMain.Sections(“foot”).CanGrow = True
'setting up the detail section
rptMain.Detail.Height = 300
rptMain.Detail.BackStyle = 0 '1 = normal 0 = transparent
rptMain.Detail.BackColor = &HC0C0C0
rptMain.Detail.ColumnCount = 1
rptMain.Detail.KeepTogether = True
rptMain.Detail.CanGrow = True
rptMain.Detail.Visible = True
Now that you have everything set up, you can add Labels,Fields,Lines and everything else to your report. I’m not familiar with your exact requirements, but if you are working with records from RecordSet, then you should keep in mind that every Field control needs to have its DataField set to corresponding FieldName from the recordSet.
If you have more question, I would be glad to help!