I have an Access 2003 project (.ADP) which is a front end to a SQL Server 2005 database.
In this ADP, I have a report, which is a set of 8 unbound text boxes, stacked on top of each other each with their own labels. Each text box is for instructions for 8 different departments that will work on an order.
This report gets populated with appropriate data and displayed for the user on click of a button in a form.
Rarely do all 8 boxes get values at the same time. Most of the time, it is 2 or 3 boxes that have values.
Given this, is it possible to somehow implement a fluid layout of the boxes? ie, hide the boxes that don't have values to display, but instead of displaying an empty area, the report should move up the boxes that have instructions below the hidden box.
Is it possible through some circuitous VBA code ? If not, what other option can I try? Thank you.
EDIT - The report and the text boxes are used only to present data.
I was able to create the effect you describe by setting the "Can Shrink" properties of the textboxes to "Yes", and then adding the following code to the On Format
event of the Detail band
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.lblAccounting.Visible = Not IsNull(Me.txtAccounting.Value)
Me.txtAccounting.Visible = Not IsNull(Me.txtAccounting.Value)
Me.lblFinance.Visible = Not IsNull(Me.txtFinance.Value)
Me.txtFinance.Visible = Not IsNull(Me.txtFinance.Value)
Me.lblMarketing.Visible = Not IsNull(Me.txtMarketing.Value)
Me.txtMarketing.Visible = Not IsNull(Me.txtMarketing.Value)
Me.lblOperations.Visible = Not IsNull(Me.txtOperations.Value)
Me.txtOperations.Visible = Not IsNull(Me.txtOperations.Value)
End Sub
For the test data
ID Accounting Finance Marketing Operations
-- ---------- ------- --------- ----------
1 a1 f1 o1
2 f2 m2
I get the following result in Print Preview. I'm using Access 2010, and the On Format
tweaks apparently do not work in "Report View", but in Print Preview I get:
You'll notice that the remaining boxes may not match perfectly if some of them are "squeezed out". If your report could do without borders on the textboxes themselves then the discrepancy would be barely noticeable. Otherwise, you'll have to tweak the layout until it looks good (or at least "good enough"). That's just the way database reporting goes: spend half an hour getting the thing to work, and then spend another two hours fiddling with it to make it "look nice".