473,324 Members | 2,214 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Can a subform's window size be set programatically?

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
2 12564
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Wendy Powley | last post by:
I have a subform which represents a 1:N relationship with the main form. I would like to be able to read values from an external file, fill the subform with the values read & allow the user to...
25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
1
by: Susan | last post by:
I have a bound form and subform and am trying to enter the data in both forms programatically. The Linkmaster and Linkchild properties are set. My intent is to be able to look at the data before it...
6
by: Tom | last post by:
I have a button on a main form that executes code to write to the subform. The subform's AllowAdditions property is set to false and in the button's code the subform's AllowAdditions property is...
1
by: JaredEmery | last post by:
I am new to Access and have stumbled through building a bill-of-materials database. My main form has 4 subforms set to continuous mode that all exhibit the same scrollbar oddity: if the number of...
0
by: mpietsch | last post by:
There has been quite some discussion on this particular error when resizing forms and moving controls on them. One solution that seems to work is enlarging the form's detail-area to maximum size...
1
by: Bob Alston | last post by:
I have a system where many subforms are used. Often the size of the subform had to be larger than could be displayed without scrolling. I set the height of the subform to the typical height...
19
by: postman | last post by:
I have a parent form bound to a recordsource and several controls are bound to fields in that recordsource. There are also several unbound controls that are used to display various data in a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.