Problem with visible property

  • Thread starter Thread starter Nathan Guill
  • Start date Start date
N

Nathan Guill

I am having trouble with the .visible property functioning when I edit or
copy this code. In the original code I created, it works with no problems.
Can anyone help?

The code below is processed in the when the report is formatted before
printing. The ("D" & iCount) fields on the report are textboxes. I run
Acess 2000. I change the visibility as I don't want any empty lines to
print and I eventually (later on in the code) move then fields that come
after these to move up to the last visible field. Any onther information
needed, please let me know.

For iCount = 1 To 24
If Me("D" & iCount).Value > "" Then
'show dimension
Me("D" & iCount).Visible = True

'show label
Me("lbl" & iCount).Visible = True

'show lines
Me("l" & iCount).Visible = True
Me("l" & (iCount + 25)).Visible = True
Me("l" & (iCount + 50)).Visible = True

'Save current Top & Height
mvarLastLabelTop = Me("lbl" & iCount).Top

Else
'hide dimension
Me("D" & iCount).Visible = False

'hide label
Me("lbl" & iCount).Visible = False

'hide lines
Me("l" & iCount).Visible = False
Me("l" & (iCount + 25)).Visible = False
Me("l" & (iCount + 50)).Visible = False
End If
Next iCount
 
You don't say what error or result you are seeing.

It may help to assign a string variable to the name, and use that, e.g.:
Dim strCtl As String
strCtl = "D" & iCount
Me(strCtl).Visible = ...

If the labels are attached, there is no need to set their Visible property.

Would it be easier to set the CanShrink property of the controls to Yes so
they automatically collapse when they have no data? To make their labels
disappear also, change the labels into text boxes that have this sort of
ControlSource:
=IIf(IsNull([D1]), Null, "D1")
You will need to ensure the controls don't overlap each other, or overlap
vertically, and also check that the CanShrink property of the Detail section
is Yes.

Better still, there might be a way to normalize this data so that it does
not have D1 to D25 as field names?
 
Back
Top