Hello, all.
First, let me thank everyone for the help I've gotten over the last few days. I've made more progress in these few days than I have in weeks.
With that, I've another question for the board:
I'm creating a dynamic report and I need to create field headers based on fields in a query. The query has job number, hours, job name and a field for each person.
Here's the code I've written so far:
When I run it, I get an error that says I must be in design mode to add or remove controls. I thought that it could be done programmatically.
Can this only be done with pure code and not an OnOpen event?
Any help?
thanks in advance...
Mike
First, let me thank everyone for the help I've gotten over the last few days. I've made more progress in these few days than I have in weeks.
With that, I've another question for the board:
I'm creating a dynamic report and I need to create field headers based on fields in a query. The query has job number, hours, job name and a field for each person.
Here's the code I've written so far:
Code:
Private Sub Report_Open(Cancel As Integer)
' Create headers of staff names
Dim db As DAO.Database
Dim qry As DAO.QueryDef
Dim fld As DAO.Field
Dim rpt As Report
Dim ctl As Control
Dim i As Integer
Set db = CurrentDb
Set qry = db.QueryDefs("qryHourProjections_Crosstab")
Set rpt = Reports("rptHourProjections")
i = 1
For Each fld In qry.Fields
If (fld.Name <> "JobNumber") And (fld.Name <> "JobDescription") And (fld.Name <> "Total of Total of Hours") Then
' For each staff field, create a label
'Set ctl = CreateReportControl(rpt.Name, acLabel, acPageHeader, , fld.Name, 20 + 100 * (i - 1), 40)
Set ctl = CreateReportControl(rpt.Name, acLabel, acPageHeader, , fld.Name, 20 + 100 * (i - 1), 40)
End If
Next
End Sub
When I run it, I get an error that says I must be in design mode to add or remove controls. I thought that it could be done programmatically.
Can this only be done with pure code and not an OnOpen event?
Any help?
thanks in advance...
Mike