Code:
Private Sub cmdFlowShutter_Click() Dim spaceBetween As Integer, origTop As Integer
If cmdFlowShutter.Caption = "-" Then
cmdFlowShutter.SetFocus
frmSubFlow.Visible = False
spaceBetween = lblWL.Top - frmSubFlow.Top - frmSubFlow.Height
origTop = lblWL.Top
lblWL.Top = lblFlow.Top + lblFlow.Height + spaceBetween
cmdWLShutter.Top = cmdWLShutter.Top - (origTop - lblWL.Top)
boxWL.Top = boxWL.Top - (origTop - lblWL.Top)
frmSubWL.Top = lblWL.Top + lblWL.Height ' Or frmSubWL.top = frmSubWL.top - (origtop - lblWL.top) (not tried but should work)
cmdFlowShutter.Caption = "+"
Else
spaceBetween = lblWL.Top - lblFlow.Top - lblFlow.Height
origTop = lblWL.Top
lblWL.Top = frmSubFlow.Top + frmSubFlow.Height + spaceBetween
cmdWLShutter.Top = cmdWLShutter.Top + (lblWL.Top - origTop)
boxWL.Top = boxWL.Top + (lblWL.Top - origTop)
frmSubWL.Top = lblWL.Top + lblWL.Height
frmSubFlow.Visible = True
cmdFlowShutter.SetFocus ' Maybe setfocus to the Flow id or comment or other field in Flow subform.
cmdFlowShutter.Caption = "-"
End If
End Sub
Private Sub cmdWLShutter_Click()
If cmdWLShutter.Caption = "-" Then
cmdWLShutter.SetFocus
frmSubWL.Visible = False
cmdWLShutter.Caption = "+"
Else
frmSubWL.Visible = True
cmdWLShutter.SetFocus ' Maybe setfocus to the WL id or comment or other field in WL subform.
cmdWLShutter.Caption = "-"
End If
End Sub
Private Sub cmdCondShutter_Click()
If cmdCondShutter.Caption = "-" Then
cmdCondShutter.SetFocus
frmSubCond.Visible = False
cmdCondShutter.Caption = "+"
Else
frmSubCond.Visible = True
cmdCondShutter.SetFocus ' Maybe setfocus to the WL id or comment or other field in WL subform.
cmdCondShutter.Caption = "-"
End If
End Sub
This works great for TWO sub-forms but once I add more everything breaks down due to the difference between the spacing of the top collapsed form and the furthest down gets whacky and since I have ~6 sub-forms I want to add, this won't really scale properly. I'm not very good at VBA to create a function that might better do this. Should I just scrap expanding/collapsing sub-forms? I just like that you can pull all the different data for a station and display it at once which allows you to compare calibration times...