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".