Option Compare Database
Option Explicit
Private Sub chk1_AfterUpdate()
'If chk1 = True Then B1.Visible = True: B1.Height = 380: Box1.Visible = True: Box1.Height = 850 Else: B1.Visible = False: B1.Height = 0: Box1.Visible = False: Box1.Height = 0
Call ArrangeBoxes
End Sub
Private Sub chk2_AfterUpdate()
'If chk2 = True Then B2.Visible = True: B2.Height = 380: Box2.Visible = True: Box2.Height = 850 Else: B2.Visible = False: B2.Height = 0: Box2.Visible = False: Box2.Height = 0
Call ArrangeBoxes
End Sub
Private Sub chk3_AfterUpdate()
'If chk3 = True Then B3.Visible = True: B3.Height = 380: Box3.Visible = True: Box3.Height = 850 Else: B3.Visible = False: B3.Height = 0: Box3.Visible = False: Box3.Height = 0
Call ArrangeBoxes
End Sub
Private Sub chk4_AfterUpdate()
'If chk4 = True Then B4.Visible = True: B4.Height = 380: Box4.Visible = True: Box4.Height = 850 Else: B4.Visible = False: B4.Height = 0: Box4.Visible = False: Box4.Height = 0
Call ArrangeBoxes
End Sub
Private Sub Form_load()
'Call chk1_AfterUpdate
'Call chk2_AfterUpdate
'Call chk3_AfterUpdate
'Call chk4_AfterUpdate
Call ArrangeBoxes
End Sub
Private Function ArrangeBoxes() As Boolean
Const BTN_HEIGHT As Integer = 380
Const BOX_HEIGHT As Integer = 850
Const BTN_TOP As Integer = 1230
Const BOX_TOP As Integer = 285
Dim iCount As Integer, iVisible As Integer, i As Integer
iVisible = 0
For i = 1 To 4
iVisible = iVisible - Me("chk" & i)
With Me("B" & i)
.Visible = Me("chk" & i)
.Top = BTN_TOP + (iVisible * BTN_HEIGHT)
End With
With Me("Box" & i)
.Visible = Me("Chk" & i)
.Top = BOX_TOP + (iVisible * BOX_HEIGHT)
End With
Next i
ArrangeBoxes = Err = 0
End Function