Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old October 9th, 2006, 04:55 PM
afr0ninja
Guest
 
Posts: n/a
Default Start Form Default Size then Expand With Command Button

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!

  #2  
Old October 10th, 2006, 01:25 AM
ray@aic.net.au
Guest
 
Posts: n/a
Default Re: Start Form Default Size then Expand With Command Button

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:
Quote:
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!
  #3  
Old October 10th, 2006, 10:35 AM
Terry Kreft
Guest
 
Posts: n/a
Default Re: Start Form Default Size then Expand With Command Button

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


<ray@aic.net.auwrote in message
news:1160440647.398326.249960@e3g2000cwe.googlegro ups.com...
Quote:
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:
Quote:
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!
>

  #4  
Old October 12th, 2006, 10:15 PM
afr0ninja
Guest
 
Posts: n/a
Default Re: Start Form Default Size then Expand With Command Button

Code works great! Thank you both for your assistance!!

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles