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

Can a subform's window size be set programatically?

P: n/a
I have two subforms within a particular form. The one on top is a datasheet
of transactions; the one on the bottom is a summary of totals. I would like
to have the datasheet fill the entire parent form until a command button is
clicked, then have the datasheet form shrunk to half it's original height
and have the totals summary form appear below it. The totals summary sheet,
then, would not be visible until the command button is clicked, and would
reside behind the datasheet form in it's invisible state. I've tried
setting the window height property, but I get an error telling me it's a
read only property.

Has anyone done something like this before?

thanks in advance...
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
deko wrote:
I have two subforms within a particular form. The one on top is a datasheet
of transactions; the one on the bottom is a summary of totals. I would like
to have the datasheet fill the entire parent form until a command button is
clicked, then have the datasheet form shrunk to half it's original height
and have the totals summary form appear below it. The totals summary sheet,
then, would not be visible until the command button is clicked, and would
reside behind the datasheet form in it's invisible state. I've tried
setting the window height property, but I get an error telling me it's a
read only property.

Has anyone done something like this before?

thanks in advance...


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sounds like you have 2 subforms in a main form, correct?

You'd just modify the subform Control's left, top, width and height
properties - that will change the size of the subform controls on the
main form. You could also set up the subforms so they are both the
same size & cover the same area on the main form (not recommended by
Microsoft, but sometimes useful) & use the subform Visible property to
hide one and display the other.

E.g.: Main form name = "frmMain"
Subform 1 name = "sfrmTotals"
Subform 2 name = "sfrmTransactions"

To hide sfrmTotals - VBA code in frmMain:

Private Sub cmdTotals_Click()

Me!sfrmTransactions.Visible = False
Me!sfrmTotals.Visible = True

End Sub

You'd have to have another button that does the reverse - or - you
could make the same button do the work for both like this:

Private Sub cmdTotals_Click()

Static fTotals as Boolean

' First time thru fTotals will become True
fTotals = Not fTotals

If fTotals Then
me!cmdTotals.Caption = "Totals"
Else
me!cmdTotals.Caption = "Transactions"
End If

Me!sfrmTotals.Visible = fTotals
Me!sfrmTransactions.Visible = not fTotals

End Sub

The beginning state of the form should be showing transactions. When
the CommandButton "Totals" is clicked it will flip the fTotals boolean
(change it to its opposite), change the caption of the CommandButton,
and hide the subforms according to the new state.

Be sure to test this since I sometimes get the states mixed up - just
make sure that when the CommandButton caption = "Totals" that the
Totals subform is showing and vice-versa. To fix just move the "NOT"
from one .Visible assignment to the other until it looks correct.

HTH,

MGFoster:::mgf
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP4ZapYechKqOuFEgEQJU8gCgxsfdiAV9ml6wEi34NoWfXA WrXqEAoP1o
mCv/1TlUD3sXcbQ6RtPtGzaL
=UsF6
-----END PGP SIGNATURE-----

Nov 12 '05 #2

P: n/a
outstanding!!

Thanks for the help!

These simple lines of code accomplish the result I was looking for:

Form_frmTxTotal_Ac.Visible = False
Form_frmAc.frmTxHist_Ac.Height = 6540 ' measurement in twips --
1440 = 1"
And
Me.frmTxHist_Ac.Height = 4035
Form_frmTxTotal_Ac.Visible = True

as for testing for current state... still working on this... but the key
issue is resolved - thanks to your help
"MGFoster" <me@privacy.com> wrote in message
news:rU*****************@newsread4.news.pas.earthl ink.net...
deko wrote:
I have two subforms within a particular form. The one on top is a datasheet of transactions; the one on the bottom is a summary of totals. I would like to have the datasheet fill the entire parent form until a command button is clicked, then have the datasheet form shrunk to half it's original height and have the totals summary form appear below it. The totals summary sheet, then, would not be visible until the command button is clicked, and would reside behind the datasheet form in it's invisible state. I've tried
setting the window height property, but I get an error telling me it's a
read only property.

Has anyone done something like this before?

thanks in advance...


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sounds like you have 2 subforms in a main form, correct?

You'd just modify the subform Control's left, top, width and height
properties - that will change the size of the subform controls on the
main form. You could also set up the subforms so they are both the
same size & cover the same area on the main form (not recommended by
Microsoft, but sometimes useful) & use the subform Visible property to
hide one and display the other.

E.g.: Main form name = "frmMain"
Subform 1 name = "sfrmTotals"
Subform 2 name = "sfrmTransactions"

To hide sfrmTotals - VBA code in frmMain:

Private Sub cmdTotals_Click()

Me!sfrmTransactions.Visible = False
Me!sfrmTotals.Visible = True

End Sub

You'd have to have another button that does the reverse - or - you
could make the same button do the work for both like this:

Private Sub cmdTotals_Click()

Static fTotals as Boolean

' First time thru fTotals will become True
fTotals = Not fTotals

If fTotals Then
me!cmdTotals.Caption = "Totals"
Else
me!cmdTotals.Caption = "Transactions"
End If

Me!sfrmTotals.Visible = fTotals
Me!sfrmTransactions.Visible = not fTotals

End Sub

The beginning state of the form should be showing transactions. When
the CommandButton "Totals" is clicked it will flip the fTotals boolean
(change it to its opposite), change the caption of the CommandButton,
and hide the subforms according to the new state.

Be sure to test this since I sometimes get the states mixed up - just
make sure that when the CommandButton caption = "Totals" that the
Totals subform is showing and vice-versa. To fix just move the "NOT"
from one .Visible assignment to the other until it looks correct.

HTH,

MGFoster:::mgf
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP4ZapYechKqOuFEgEQJU8gCgxsfdiAV9ml6wEi34NoWfXA WrXqEAoP1o
mCv/1TlUD3sXcbQ6RtPtGzaL
=UsF6
-----END PGP SIGNATURE-----

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.