expand and retract form procedure

A

AccessARS

I have a form which is being used to enter criteria of a report. While this
form is open I would like to have an "Advanced>>" command that would
drop/expand the bottom of the form with additional search options.

My attempt: I inserted a sub form with the additional search options on the
footer of the main form minimized in design view with the following
properties, can grow, can shrink and not visible. In the main form I set the
properties to can and can shrink. My expectations were to have the procedure
behind the command set the sub-form visible property to TRUE. Although the
Sub-Form appears the Footer does not expand therefore it overlaps. I also
placed it on the bottom of Detail but it just didn’t allow the sub-form to
grow or overlap.

Thank you in advance for your time.
 
S

Steve Sanford

Maybe this will help...

1) In a form, in the form header add a button (mine is named Command11).

2) In the form footer, add 3 text boxes.

My text boxes were named "Text17" (and the label "Label18"), "Text 19"
("Label20") and "Text21" ("Label22").

3) In design view, for all the text boxes and labels, set the top at 0.05".

For each of the text boxes and labels set:

"Label18" - Left = 0.25"
"Text17" - Left = 1"

"Label20" - Left = 2.2"
"Text19" - Left = 2.7"

"Label22" - Left = 4"
"Text21" - Left = 4.7"

4) Set the form footer height = 0.25"
5) Set the caption for the button to "Advanced>>"

6) Add the code for the button:

'-----code beg-------
Private Sub Command11_Click()
Dim strCaption As String
Const vbGray = 12632256

strCaption = Me.Command11.Caption

Select Case strCaption
Case "Advanced>>"
'expand the footer
Me.FormFooter.BackColor = vbWhite
' set footer height = 2"
' 1 inch = 1440 twips
Me.FormFooter.Height = 2 * 1440

'show text boxes in the footer
Me.Text17.Visible = True
Me.Text17.Left = 1 * 1440
Me.Text17.top = 0.05 * 1440
'attached label for Text17
Me.Label18.Left = 0.25 * 1440
Me.Label18.top = 0.05 * 1440
Me.Label18.Visible = True

Me.Text19.Visible = True
Me.Text19.Left = 1 * 1440
Me.Text19.top = 0.35 * 1440
'attached label for Text19
Me.Label20.Left = 0.25 * 1440
Me.Label20.top = 0.35 * 1440
Me.Label20.Visible = True

Me.Text21.Visible = True
Me.Text21.Left = 1 * 1440
Me.Text21.top = 0.7 * 1440
'attached label for Text21
Me.Label22.Left = 0.25 * 1440
Me.Label22.top = 0.7 * 1440
Me.Label22.Visible = True
Me.Command11.Caption = "<<Hide"

Case Else
'hide text boxes in the footer
Me.Text17.Visible = False
Me.Text17.Left = 1 * 1440
Me.Text17.top = 0.05 * 1440
'attached label for Text17
Me.Label18.Left = 0.25 * 1440
Me.Label18.top = 0.05 * 1440
Me.Label18.Visible = False

Me.Text19.Visible = False
Me.Text19.Left = 2.7 * 1440
Me.Text19.top = 0.05 * 1440
'attached label for Text19
Me.Label20.Left = 2.2 * 1440
Me.Label20.top = 0.05 * 1440
Me.Label20.Visible = False

Me.Text21.Visible = False
Me.Text21.Left = 4.7 * 1440
Me.Text21.top = 0.05 * 1440
'attached label for Text21
Me.Label22.Left = 4 * 1440
Me.Label22.top = 0.05 * 1440
Me.Label22.Visible = False

'Hide the footer
Me.FormFooter.BackColor = vbGray
Me.FormFooter.Height = 0.25 * 1440

Me.Command11.Caption = "Advanced>>"
End Select

End Sub
'-----code end-------


HTH
 
A

AccessARS

Thank you...this is definitly a working option but I was able to make my
subform work with the docmd.movesize action on the main form.
 

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