Solved Changing Form's width (1 Viewer)

KitaYama

Well-known member
Local time
Today, 18:20
Joined
Jan 6, 2022
Messages
1,541
Yes, thanks.

The problem seems to to be that the main form is set up as a dialog form, so you can't resize it other than in code.
Make it sizable instead, and you should be OK.
Yes, And as I explained in #10, making the form sizable solves this simple form, but didn't work for my main form.
Maybe because it's filled with a lot more controls and possibly a tab control at the left.
I'm on holidays and when I go back to work, I'll try to upload another form that shows the exact same problem even when it's sizable.
And it would be 3 days later.

I don't have a PC at home. Only tablets.
Thanks for trying to help.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 10:20
Joined
Sep 12, 2006
Messages
15,656
After posting that, I added some notes about the sizetofitform method in my post.

See this modified version. I moved your command1 button to the left so it's visible when the form is narrow, and changed the text.
Version 2a replaces an earlier version 2.

Your checkbox toggles and sets the form to a different width, depending on whether its checked or not. It's not quite as wide as the full width, though. I don't see why this wouldn't work on any form, but clearly not a subform. You might get a "not available right now" response with a subform.
 

Attachments

  • Database2a.accdb
    1.1 MB · Views: 55
Last edited:

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 10:20
Joined
Sep 12, 2006
Messages
15,656
With regard to cutting off the left side, I have seen that before with forms opened for the first time. I think Access makes a decision about the best way to display the form. If you resize it so its wide enough to show everything then it fixes the issue, but you can't resize a dialog form.

See this version with a slightly wider starting position, and a horizontal scroll bar.
 

Attachments

  • Database2b.accdb
    484 KB · Views: 57

KitaYama

Well-known member
Local time
Today, 18:20
Joined
Jan 6, 2022
Messages
1,541
@gemma-the-husky
Holidays are over. I'm back to my job.
I really appreciate your efforts to help, here and via PM, but to be honest, I can't understand what you're trying to show.
Your sample #22 shows that left side of the controls are cut off. Just the same as my original file.
In the sample #22, you have a scrollbar that can be scrolled and show all objects. The subform in the right side is available.
I think you haven't read my first post carefully.

Here's what I said if you missed it:
1- the orientation is set left-to-right
2- I change the width of the form in open or load events.
My question was :
Does anybody know why Access cuts off the left side too? Normally the left top is 0,0 coordinates. And the width is 0+insideWidth property.
If I change the insidewidth property in onload event, the form width doesn't start from 0. You can see that all the objects in left side are cutoff.
Again, my question is why the form width doesn't start from 0?

@Edgar_ asked me to change the border to sizable. Sometimes his solution works. sometimes doesn't.

Here's another sample to show what I mean.


Note: I have a work around to have the result I need (#13). You may want not to waste your time on a question that is solved with a workaround, though I still appreciate if you have the answer and tell me why the left side is cut off too.

Thanks again.
 

Attachments

  • Database1.accdb
    684 KB · Views: 56
Last edited:

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 10:20
Joined
Sep 12, 2006
Messages
15,656
I suspect that Access automatically adjusts the visible area of a form when it is not wide enough to show all the controls. Maybe the visible area on the left shows all or part of the left most control, but not all of any blank space. As you resize the form it gets to a point where it can show all the controls.

I see that behaviour when forms open to a smaller size than they need to be to see the entire form. Maybe you only see the left hand cut-off effect if the visible size is less than a certain percentage of the full form size. It doesn't bother me unduly when it happens, because I resize the form anyway, and as the form grows in size, the missing left part appears at some point.

I generally either resize forms to the users desired size or resize the form to its full design size when the form opens. (acCmdSizeToFitForm).
You could also add a horizontal scroll bar to enable users to see the whole of the form content.

You said the resize to full size command doesn't work in your form, but I don't understand why it wouldn't, although maybe in some cases the command isn't available.
 

KitaYama

Well-known member
Local time
Today, 18:20
Joined
Jan 6, 2022
Messages
1,541
You said the resize to full size command doesn't work in your form, but I don't understand why it wouldn't, although maybe in some cases the command isn't available.
I didn't say it doesn't work. I said it's not what I want. I don't want to change the size to full size. I want to change the size narrower than what it is. (to hide some objects at the right side of the form)
I think we're going in circles now.

gemma-the-husky said:
RunCommand acCmdSizeToFitForm
which makes the form large enough to display the full form design.
My current problem is the opposite. The problem occurs when the width of the form is less than the actual size.
So acCmdSizeToFitForm can not be used in this case.

Thanks again.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 04:20
Joined
Feb 28, 2001
Messages
27,186
At this point I would bite the bullet and write some code to sample the form's properties (before and after resizing) and write them to a file. Somewhere in there you should find whatever settings have been "jiggered" to cause this effect.
 

KitaYama

Well-known member
Local time
Today, 18:20
Joined
Jan 6, 2022
Messages
1,541
At this point I would bite the bullet and write some code to sample the form's properties (before and after resizing) and write them to a file. Somewhere in there you should find whatever settings have been "jiggered" to cause this effect.
@The_Doc_Man Thanks for jumping in.
I'll try that and see if anything changes.
 

isladogs

MVP / VIP
Local time
Today, 10:20
Joined
Jan 14, 2017
Messages
18,224
PMFJI.
When a form opens, focus normally goes to the first control in the tab order which in your case is a listbox somewhere near the centre horizontally of your form. If the form isn't large enough for all controls the form is shifted horizontally and/or vertically accordingly as can be seen if scrollbars are made visible.

In your case, things are further complicated by placing certain controls in a layout which is not at the top left of the form.
The focus goes to the first item in that layout so the left side is cut off.

The effect you see is Access trying to be helpful based on the 'instructions' given to it for rendering the form

To fix, move that layout with its controls to the top left or remove the layout and move another control to the top left then update the tab order

1699257923779.png
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:20
Joined
May 7, 2009
Messages
19,243
you can put 2 Line controls (just like in the demo, see in design view because it is not Visible).
and you can set the InsideWidth of the form the the .Left property of each lines.
 

Attachments

  • Database2.accdb
    1.3 MB · Views: 55

KitaYama

Well-known member
Local time
Today, 18:20
Joined
Jan 6, 2022
Messages
1,541
@isladogs I hope I've not misunderstood your advice. But

When a form opens, focus normally goes to the first control in the tab order which in your case is a listbox somewhere near the centre horizontally of your form. If the form isn't large enough for all controls the form is shifted horizontally and/or vertically accordingly as can be seen if scrollbars are made visible.
I'd thought of that. Even if I set all the controls to TabStop=NO still I see the same result.
In fact, my sample form in #1 has all the tabstops to No, still the left side is cutoff.

To fix, move that layout with its controls to the top left or remove the layout and move another control to the top left then update the tab order
This is just a test form. My real form is filled with controls from left top to bottom right, still the same result happens.
My sample form in #1 has a button in top left side. but as you see in my screenshots there, the left side is cut off too.

Thanks for looking into this problem.

Edit : I did some changes to the sample file. All controls are set to tabStop=No.
All controls that may have had the focus are set Enabled=No
While the form is opened, in immediate window if I type ?Screen.ActiveControl.Name I receive an error that shows nothing has focus.
Still the same result.
 

Attachments

  • Database1.accdb
    684 KB · Views: 65
Last edited:

KitaYama

Well-known member
Local time
Today, 18:20
Joined
Jan 6, 2022
Messages
1,541
you can put 2 Line controls (just like in the demo, see in design view because it is not Visible).
and you can set the InsideWidth of the form the the .Left property of each lines.
Yes, it works as you explained.
What I did in #13 works as well.

I wonder why this happens in first place that needs a workaround.

Thanks.
 

Users who are viewing this thread

Top Bottom