Right, I'm not entirely convinced you have the basics covered (your 2 or 3 line response didn't inspire confidence), but I will give the gist of how I would approach the problem and see where we go from there.
Any reasonable questions (not ones I consider too basic) will find me willing to post replies to. Remember I warned you before we started how this was going to work.
- Start by determining a method of passing the information from the CheckBoxes to the report.
I have a function I use for this which you're welcome to use :
- 'RptParms sets and returns a set of parameters required by a report.
-
Public Function RptParms(intSetGet As Integer, _
-
ParamArray avarParams() As Variant) As Variant
-
Static avarParms() As Variant
-
Dim intIdx As Integer
-
-
RptParms = 0
-
If intSetGet = 0 Then
-
intSetGet = UBound(avarParams) + 1 - LBound(avarParams)
-
If intSetGet < 1 Then
-
ReDim avarParms(1 To 1)
-
avarParms(1) = "Error"
-
Exit Function
-
End If
-
ReDim avarParms(1 To intSetGet)
-
For intIdx = 1 To intSetGet
-
avarParms(intIdx) = avarParams(intIdx - 1)
-
Next intIdx
-
Else
-
'If outside bounds then it drops through and is set to "Error"
-
On Error Resume Next
-
If avarParms(intSetGet) = "Error" Then
-
RptParms = "Error" 'On Error
-
Else
-
RptParms = avarParms(intSetGet)
-
End If
-
End If
-
End Function
Call the function before opening the report using intSetGet = 0 (and passing the string of required fields in avarParms) to pass the information on to the report.
From within the report, call the function again (RptParms(1)) to pick up the string of fields that are required. - Design a report with ALL the possible columns in it. We intend to hide columns that we don't need rather than create any new columns on the fly.
- In the reports Open event procedure, add code which handles all of the following :
- Processes the string of fields required.
- Processes through all the fields and sets only those which are required to visible. All others should be hidden.
- Processes through all the visible (displayed) fields setting their start positions (start pos + width of the previous field) and optionally, their widths. It may be that too many fields mean that some of the columns have to squeeze up.
- Sets the width of the report itself to match the width of the fields displayed (Try to - I'm not positive this can even work). This may not be necessary or what you want, but it's a consideration. I'll leave that up to you to decide on.
If I've missed anything out or you can't understand how I've explained something, that's fine to ask for clarification on.
Good luck.