P
Peter Stone
Good Evening
Novice
I have some code that hides controls if they are empty and then moves the
last two controls up (then down) the form so there aren't blank spaces.
It works fine, but I'm sure there's a neater way.
Note: the controls move 1cm at a time (567 twips to the cm).
Private Sub Form_Current()
'hide the contols if they have no text
txtRegionA.Visible = Not IsNull(RegionA)
txtRegionB.Visible = Not IsNull(RegionB)
txtRegionC.Visible = Not IsNull(RegionC)
txtRegionD.Visible = Not IsNull(RegionD)
txtRegionE.Visible = Not IsNull(RegionE)
txtUrbanA.Visible = Not IsNull(UrbanA)
txtUrbanB.Visible = Not IsNull(UrbanB)
'move the Urban labels and controls up if the Region controls have no text
If txtAlternateRegionA.Visible = No Then
lblUrbanA.Top = 3.2 * 567
txtUrbanA.Top = 3.6 * 567
lblUrbanB.Top = 4.2 * 567
txtUrbanB.Top = 4.6 * 567
Else
If txtAlternateRegionB.Visible = No Then
lblUrbanA.Top = 4.2 * 567
txtUrbanA.Top = 4.6 * 567
lblUrbanB.Top = 5.2 * 567
txtUrbanB.Top = 5.6 * 567
Else
If txtAlternateRegionC.Visible = No Then
lblUrbanA.Top = 5.2 * 567
txtUrbanA.Top = 5.6 * 567
lblUrbanB.Top = 6.2 * 567
txtUrbanB.Top = 6.6 * 567
Else
If txtAlternateRegionD.Visible = No Then
lblUrbanA.Top = 6.2 * 567
txtUrbanA.Top = 6.6 * 567
lblUrbanB.Top = 7.2 * 567
txtUrbanB.Top = 7.6 * 567
Else
If txtAlternateRegionE.Visible = No Then
lblUrbanA.Top = 7.2 * 567
txtUrbanA.Top = 7.6 * 567
lblUrbanB.Top = 8.2 * 567
txtUrbanB.Top = 8.6 * 567
Else
lblUrbanA.Top = 8.2 * 567
txtUrbanA.Top = 8.6 * 567
lblUrbanB.Top = 9.2 * 567
txtUrbanB.Top = 9.6 * 567
End If
End If
End If
End If
End If
End Sub
Thank you
Peter
Novice
I have some code that hides controls if they are empty and then moves the
last two controls up (then down) the form so there aren't blank spaces.
It works fine, but I'm sure there's a neater way.
Note: the controls move 1cm at a time (567 twips to the cm).
Private Sub Form_Current()
'hide the contols if they have no text
txtRegionA.Visible = Not IsNull(RegionA)
txtRegionB.Visible = Not IsNull(RegionB)
txtRegionC.Visible = Not IsNull(RegionC)
txtRegionD.Visible = Not IsNull(RegionD)
txtRegionE.Visible = Not IsNull(RegionE)
txtUrbanA.Visible = Not IsNull(UrbanA)
txtUrbanB.Visible = Not IsNull(UrbanB)
'move the Urban labels and controls up if the Region controls have no text
If txtAlternateRegionA.Visible = No Then
lblUrbanA.Top = 3.2 * 567
txtUrbanA.Top = 3.6 * 567
lblUrbanB.Top = 4.2 * 567
txtUrbanB.Top = 4.6 * 567
Else
If txtAlternateRegionB.Visible = No Then
lblUrbanA.Top = 4.2 * 567
txtUrbanA.Top = 4.6 * 567
lblUrbanB.Top = 5.2 * 567
txtUrbanB.Top = 5.6 * 567
Else
If txtAlternateRegionC.Visible = No Then
lblUrbanA.Top = 5.2 * 567
txtUrbanA.Top = 5.6 * 567
lblUrbanB.Top = 6.2 * 567
txtUrbanB.Top = 6.6 * 567
Else
If txtAlternateRegionD.Visible = No Then
lblUrbanA.Top = 6.2 * 567
txtUrbanA.Top = 6.6 * 567
lblUrbanB.Top = 7.2 * 567
txtUrbanB.Top = 7.6 * 567
Else
If txtAlternateRegionE.Visible = No Then
lblUrbanA.Top = 7.2 * 567
txtUrbanA.Top = 7.6 * 567
lblUrbanB.Top = 8.2 * 567
txtUrbanB.Top = 8.6 * 567
Else
lblUrbanA.Top = 8.2 * 567
txtUrbanA.Top = 8.6 * 567
lblUrbanB.Top = 9.2 * 567
txtUrbanB.Top = 9.6 * 567
End If
End If
End If
End If
End If
End Sub
Thank you
Peter