Hi Everyone,
I have added a number of text boxes to a form (more than I will ever need) and am using the following code to populate them, because the number of field will vary each time the Crosstab query runs.
Public Sub Form_Load()
Set rst = Me.Form.RecordsetClone
For i = 0 To rst.Fields.Count - 1
If i < 16 Then
Me("Text" & i + 1).ControlSource = rst.Fields(i).Name
Me("Label" & i + 1).Caption = rst.Fields(i).Name
Me("Text" & i + 1).ColumnHidden = False
Me("Text" & i + 1).ColumnWidth = -2
End If
Next
For i = i + 1 To 16
Me("Text" & i).ColumnHidden = True
Next
Set rst = Nothing
End Sub
This works really well, I am now trying to add some totals in the Form Footer for each column, I have tried various ideas but the text box field in the footer just says error. Can anyone give me an idea how I might be able to do this?
Thanks
Neill
I have added a number of text boxes to a form (more than I will ever need) and am using the following code to populate them, because the number of field will vary each time the Crosstab query runs.
Public Sub Form_Load()
Set rst = Me.Form.RecordsetClone
For i = 0 To rst.Fields.Count - 1
If i < 16 Then
Me("Text" & i + 1).ControlSource = rst.Fields(i).Name
Me("Label" & i + 1).Caption = rst.Fields(i).Name
Me("Text" & i + 1).ColumnHidden = False
Me("Text" & i + 1).ColumnWidth = -2
End If
Next
For i = i + 1 To 16
Me("Text" & i).ColumnHidden = True
Next
Set rst = Nothing
End Sub
This works really well, I am now trying to add some totals in the Form Footer for each column, I have tried various ideas but the text box field in the footer just says error. Can anyone give me an idea how I might be able to do this?
Thanks
Neill