By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,896 Members | 2,185 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,896 IT Pros & Developers. It's quick & easy.

Start Form Default Size then Expand With Command Button

P: n/a
Hello! I'm currently working on a form that has several input fields
and a subform. What I'm trying to accomplish is that when I first open
the form I'd like to have the input fields displayed only. The fields
are about 3" wide. Then I'd like to have a command button that when
pushed it would expand the form to about 9" displaying the subform
along with the input fields. The command button could then be pressed
again to shrink the form back to it's origional 3" size.

I've tried hiding the subform (which leaves a huge blank spot on the
screen) and I've tried using me.windowwidth and me.width which give me
error on form load.

I'm pretty new to code still, so any suggestions or ideas would be
greatly appreciated. Thank you in advance!

Oct 9 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
ray
This works for me:

Put a command button on the form called cmdShow. Set its caption to
"Show >>"

In its OnClick event, put:
If Me!cmdShow.Caption = "Show >>" then
Me!cmdShow.Caption = "Hide <<"
Docmd.MoveSize 1500, 900, 9500, 5700
Else
Me!cmdShow.Caption = "Show >>"
DoCmd.MoveSize 1500, 900, 6060, 5700
End If

In this case, the Show button makes the form wider. You could change
the MoveSize parameters to make it longer instead if you prefer.

HTH,

Ray

afr0ninja wrote:
Hello! I'm currently working on a form that has several input fields
and a subform. What I'm trying to accomplish is that when I first open
the form I'd like to have the input fields displayed only. The fields
are about 3" wide. Then I'd like to have a command button that when
pushed it would expand the form to about 9" displaying the subform
along with the input fields. The command button could then be pressed
again to shrink the form back to it's origional 3" size.

I've tried hiding the subform (which leaves a huge blank spot on the
screen) and I've tried using me.windowwidth and me.width which give me
error on form load.

I'm pretty new to code still, so any suggestions or ideas would be
greatly appreciated. Thank you in advance!
Oct 10 '06 #2

P: n/a
Just a minor critique of the code shown. If you are going to compare string
literals you are better off declaring consts. That way you are much less
likely to have a typo bug.

So the "better way" to write the code below would be:-

Const CMD_CAPTION_SHOW = "Show >>"
Const CMD_CAPTION_HIDE = "Hide <<"

If Me!cmdShow.Caption = CMD_CAPTION_SHOW then
Me!cmdShow.Caption = CMD_CAPTION_HIDE
Docmd.MoveSize 1500, 900, 9500, 5700
Else
Me!cmdShow.Caption = CMD_CAPTION_SHOW
DoCmd.MoveSize 1500, 900, 6060, 5700
End If

--

Terry Kreft
<ra*@aic.net.auwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
This works for me:

Put a command button on the form called cmdShow. Set its caption to
"Show >>"

In its OnClick event, put:
If Me!cmdShow.Caption = "Show >>" then
Me!cmdShow.Caption = "Hide <<"
Docmd.MoveSize 1500, 900, 9500, 5700
Else
Me!cmdShow.Caption = "Show >>"
DoCmd.MoveSize 1500, 900, 6060, 5700
End If

In this case, the Show button makes the form wider. You could change
the MoveSize parameters to make it longer instead if you prefer.

HTH,

Ray

afr0ninja wrote:
Hello! I'm currently working on a form that has several input fields
and a subform. What I'm trying to accomplish is that when I first open
the form I'd like to have the input fields displayed only. The fields
are about 3" wide. Then I'd like to have a command button that when
pushed it would expand the form to about 9" displaying the subform
along with the input fields. The command button could then be pressed
again to shrink the form back to it's origional 3" size.

I've tried hiding the subform (which leaves a huge blank spot on the
screen) and I've tried using me.windowwidth and me.width which give me
error on form load.

I'm pretty new to code still, so any suggestions or ideas would be
greatly appreciated. Thank you in advance!

Oct 10 '06 #3

P: n/a
Code works great! Thank you both for your assistance!!

Oct 12 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.