Sizing a form with code

bknight
BronzeLounger
Posts: 1389
Joined: 08 Jul 2016, 18:53

Sizing a form with code

Post by bknight »

Currently I have one form that opens somewhat smaller than I would prefer I can view the width in the property sheet, but there is no height that I see. So, is there a way to code in a specific height? The top image is more what I'm expecting, whereas the lower image or smaller is what opens.
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Sizing a form with code

Post by HansV »

Have you set the AutoResize property of the form to Yes?

By the way, I'd set the Record Selectors and Navigation Buttons properties to No, and also the Min Max Buttons property.
Best wishes,
Hans

User avatar
SpeakEasy
4StarLounger
Posts: 550
Joined: 27 Jun 2021, 10:46

Re: Sizing a form with code

Post by SpeakEasy »

Have a quick look at runtime properties: InsideHeight and InsideWidth

e,g

Code: Select all

Private Sub Form_Open(Cancel As Integer)
    Me.InsideHeight = 600
    Me.InsideWidth = 2600
End Sub

bknight
BronzeLounger
Posts: 1389
Joined: 08 Jul 2016, 18:53

Re: Sizing a form with code

Post by bknight »

All were set to yes or enable. Reset to no and not enabled. But still opens as shown. Perhaps the Inside code might work. Another thought; scroll bars neither and split form size.
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Sizing a form with code

Post by HansV »

I'd set Scroll Bars to None, indeed.
Split Form Size doesn't matter since it is not a split form.
Try increasing the height of the Detail section of the form (assuming that the button is in that section).
Best wishes,
Hans

bknight
BronzeLounger
Posts: 1389
Joined: 08 Jul 2016, 18:53

Re: Sizing a form with code

Post by bknight »

SpeakEasy wrote:
11 Apr 2023, 11:24
Have a quick look at runtime properties: InsideHeight and InsideWidth

e,g

Code: Select all

Private Sub Form_Open(Cancel As Integer)
    Me.InsideHeight = 600
    Me.InsideWidth = 2600
End Sub
With this added the form opens as shown. I don't know how you selected those values but it works.
Thanks to both of you.
You do not have the required permissions to view the files attached to this post.

User avatar
SpeakEasy
4StarLounger
Posts: 550
Joined: 27 Jun 2021, 10:46

Re: Sizing a form with code

Post by SpeakEasy »

>I don't know how you selected those values

Created the form, opened it in Form view, sized it how I wanted then ran

Print Form_Form1.InsideHeight

and

Print Form_Form1.InsideWidth

in the VBA IDE immediate window

bknight
BronzeLounger
Posts: 1389
Joined: 08 Jul 2016, 18:53

Re: Sizing a form with code

Post by bknight »

SpeakEasy wrote:
11 Apr 2023, 13:10
>I don't know how you selected those values

Created the form, opened it in Form view, sized it how I wanted then ran

Print Form_Form1.InsideHeight

and

Print Form_Form1.InsideWidth

in the VBA IDE immediate window
Clever.

bknight
BronzeLounger
Posts: 1389
Joined: 08 Jul 2016, 18:53

Re: Sizing a form with code

Post by bknight »

Now this worked for the form I was asking, however another form in the same Db produces an error.
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Sizing a form with code

Post by HansV »

Use Debug.Print instead of Print
Best wishes,
Hans

bknight
BronzeLounger
Posts: 1389
Joined: 08 Jul 2016, 18:53

Re: Sizing a form with code

Post by bknight »

Same error message

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Sizing a form with code

Post by HansV »

How about

Debug.Print Forms!frmAction.InsideHeight
Debug.Print Forms!frmAction.InsideWidth

The form must be open when you try this!
Best wishes,
Hans

bknight
BronzeLounger
Posts: 1389
Joined: 08 Jul 2016, 18:53

Re: Sizing a form with code

Post by bknight »

That worked. I don't understand why the first one worked like Speak Easy suggested, but it is all good.
Where could I download a set of the methods of Me.---- for reference?

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Sizing a form with code

Post by HansV »

Me can have different meanings. In the code module of a form, Me refers to (the active instance of) the form, and in the code module of a report, it refers to (the active instance of) the report.
(And, more technically, in a class module, Me refers to the active instance of that module, but you don;t have to worry about that, at least for now).

Reference for the Form object - links to events, methods and properties near the bottom.
Reference for the Report object - idem.
Best wishes,
Hans

bknight
BronzeLounger
Posts: 1389
Joined: 08 Jul 2016, 18:53

Re: Sizing a form with code

Post by bknight »

I saw a max records property, what is the default value for 2007? Seems to me that '97 was something like 5000, IIRC.

User avatar
SpeakEasy
4StarLounger
Posts: 550
Joined: 27 Jun 2021, 10:46

Re: Sizing a form with code

Post by SpeakEasy »

I don't think the maxrecords property does what you think. It is a property you can set to limit the maximum number of records a query will return (assuming the provider honours it), or can read to see what the maximum will be (by default , it is 0 which mean return all records). It is NOT a report of the number of actual records in a recordset

Note that in Access 97 there was no limit to the number of actual records in a table, just a 1GB limit to the size of the table. In later versions this was bumped up to 2GB

bknight
BronzeLounger
Posts: 1389
Joined: 08 Jul 2016, 18:53

Re: Sizing a form with code

Post by bknight »

SpeakEasy wrote:
12 Apr 2023, 07:58
I don't think the maxrecords property does what you think. It is a property you can set to limit the maximum number of records a query will return (assuming the provider honours it), or can read to see what the maximum will be (by default , it is 0 which mean return all records). It is NOT a report of the number of actual records in a recordset

Note that in Access 97 there was no limit to the number of actual records in a table, just a 1GB limit to the size of the table. In later versions this was bumped up to 2GB
You're probably correct. But it was A95 MS course in the mid to late 90's, and I was in charge of writing code to download and manipulate very large mounts of data. I had no idea how o do that and I was sent to the course. Its been about 30 years ago and I don't remember all the details, but I do remember the lecturer indicating that there was a limit to the data and I needed to set a limit near where I believed the max records would be. I may be misremembering. I have all the Dbs developed then but they are in 97 as the company bought Office 97, after the class was completed. All of the have code, to download and then manipulate data. I can't open them, but can change to 2007 which I have and can't see what settings were back then.