Problem with visible property

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
 
A

Allen Browne

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top