Form is Larger in Form View than in Design View (1 Viewer)

TheSearcher

Registered User.
Local time
Today, 03:23
Joined
Jul 21, 2011
Messages
304
I've had this problem before but was always able to resolve it. However, this time - no luck.
I have a form called frm_Dashboard. It is sized the way I want in both design and form view.
However, when calling it from frm_Login it becomes much bigger and takes up the entire screen.
From frm_Login: DoCmd.OpenForm "frm_Dashboard", acNormal, , , , acWindowNormal

I'll share the properties of frm_Dashboard even though this is working fine on its own. The problem only occurs when it is opened via frm_Login. Any ideas?
Thanks in advance!
autoresize = no
autocenter - yes
fit to screen = no
Overlappingwindows = Yes
Default View = Single form
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 08:23
Joined
Sep 12, 2006
Messages
15,658
when you open the form try this in the form open event.

runcommand acCmdSizeToFitForm
there's a few other possibilities as well, you will see.


It should resize to the size of the form design. Sometimes awkward with continuous forms.
 

TheSearcher

Registered User.
Local time
Today, 03:23
Joined
Jul 21, 2011
Messages
304
Thanks Gemma. I tried all of the below and none of them solved the problem.
DoCmd.RunCommand acCmdSizeToFitForm
DoCmd.RunCommand acCmdFormView
DoCmd.RunCommand acCmdSaveLayout
DoCmd.RunCommand acCmdSizeToGrid
DoCmd.RunCommand acCmdSizeToNarrowest
 

CJames

New member
Local time
Today, 00:23
Joined
Jun 22, 2022
Messages
5
Thanks Gemma. I tried all of the below and none of them solved the problem.
DoCmd.RunCommand acCmdSizeToFitForm
DoCmd.RunCommand acCmdFormView
DoCmd.RunCommand acCmdSaveLayout
DoCmd.RunCommand acCmdSizeToGrid
DoCmd.RunCommand acCmdSizeToNarrowest
Could you try something that works for me on sizing and positioning the form...

Private Sub Form_Open(Cancel As Integer)

DoCmd.MoveSize 9500, 5000, 4125, 2350

and then change these numbers yourself to size and position how you wish..

1st arg is how far right to position form, 2nd arg is how far down, 3rd arg is form width, 4th Height

End Sub

can you try that and let me know ?
 
Last edited:

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 02:23
Joined
Feb 28, 2001
Messages
27,194
Not a bad suggestion, @CJames

Just for clarification for @TheSearcher ...

A form or report refers to the upper left corner as "home" and all measurements are down or to the right. The units will be Twips (1440 to the inch), which looks like an odd unit, but if you recall, POINTS in standard text sizing are 72 to the inch. So 1 point = 20 twips.

Further note that the units "reset" to 0,0 at upper left inside a sub-form or other new window.
 

TheSearcher

Registered User.
Local time
Today, 03:23
Joined
Jul 21, 2011
Messages
304
@CJames - The form opens exactly the size I want it when opened alone. The problem is when it is opened via the login form (frm_Login). Only then does it take up the entire screen. So, when I implement your code, it opens with the MoveSize settings - but when opened via frm_Login it still takes up the entire screen. See attached sample.
Open frm_Dashboard. It opens to the size I want.
Then open frm_Login and enter these credentials:
Login: jjones
Password: test
frm_Dashboard will now take up the entire screen.
Any ideas would be greatly appreciated!
 

Attachments

  • test.accdb
    2 MB · Views: 98

CJames

New member
Local time
Today, 00:23
Joined
Jun 22, 2022
Messages
5
@CJames - The form opens exactly the size I want it when opened alone. The problem is when it is opened via the login form (frm_Login). Only then does it take up the entire screen. So, when I implement your code, it opens with the MoveSize settings - but when opened via frm_Login it still takes up the entire screen. See attached sample.
Open frm_Dashboard. It opens to the size I want.
Then open frm_Login and enter these credentials:
Login: jjones
Password: test
frm_Dashboard will now take up the entire screen.
Any ideas would be greatly appreciated!

Made some minor mods...


See what you think...

Hope anything i Did helps...

CJ
 

Attachments

  • Test_CJ.accdb
    2.9 MB · Views: 88

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 08:23
Joined
Sep 12, 2006
Messages
15,658
@TheSearcher

I just changed your startup code to this order for clarity

Code:
Else
        'DoCmd.OpenForm "frm_Dashboard", acNormal, , , , acWindowNormal ' commented out
        DoCmd.Close A_FORM, "frm_Login"
        DoCmd.OpenForm "frm_Dashboard"
        'DoCmd.Maximize ' commented out
    End If

I meant put the resizing code in the open event of the dashboard form.

Code:
Private Sub Form_Open(Cancel As Integer)
       RunCommand acCmdSizeToFitForm
End Sub

Because you hadn't commented out DoCmd.Maximize in the dashboard that fires AFTER the dashboard opens - so if you have sizing code in that form, after it opens, your dashboard them maximises the dashboard, even though you have closed the login form.
 

TheSearcher

Registered User.
Local time
Today, 03:23
Joined
Jul 21, 2011
Messages
304
CJames & Gemma - Thanks so much. My dumb mistake on the Maximize command. Anyway, both of your codes work perfectly. Thanks so much! I appreciate your help!
Just FYI. I did put Gemma's code in the open event of the dashboard form.
 

TheSearcher

Registered User.
Local time
Today, 03:23
Joined
Jul 21, 2011
Messages
304
CJames & Gemma - Thanks so much. My dumb mistake on the Maximize command. Anyway, both of your codes work perfectly. Thanks so much! I appreciate your help!
Just FYI. I did put Gemma's code in the open event of the dashboard form.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 08:23
Joined
Sep 12, 2006
Messages
15,658
It's not obvious that the DoCmd.Maximize would run on the dashboard form after you opened it.
If you hadn't closed the login form, it might well run on that. It might just do nothing in your code, as you had already closed the login form.

It might run on whichever form has the focus (which seems to be the case), so

if you did not close the login form, and then did forms!frmLogin.setfocus after opening the dashboard, and then ran DoCmd.Maximize it might maximise the login form.

It's hard to tell without trying. I didn't know for sure, and just commented it out to see if it was that.
It's the sort of thing that once you see, you file away and remember.

I tend to not include much code that runs on other forms, so I wouldn't generally try to maximise a form from another form accidentally.
If you want it to open maximised you are best putting that in the form's open event. But if you do want to manage forms externally then you can do so, as you have seen.

I do have a generic "progress form" that I use to show progress through a code loop
It has a text box for a title, and a large text box to display information.

I set a variable "p" to refer to the progress form, so I can then update the progress form by using the object p, as below

so if I run a loop, and want to open a separate form to show the progress, I use this "progress form"
the code only updates the progress form if it opened correctly.
The progress form is reusable, by any process. It's similar to manipulating the progress bar at the bottom of the access window.

Code:
dim p as form
open "frmProgress"
on error resume next
set p = forms("frmProgress")
'note that if the progress form didn't open correctly, this will fail, so we need to ignore the error, but if it did fail then p will be "nothing"

'so now we can update from p directly from a different process. 
'just test whether p is nothing first to avoid run time errors

if not p is nothing then
    p!titletext = "Special Processing"  titletext is an unbound textbox on frmProgress
end if

while not end of processingloop
      'update the progress form to show the record details
      update a recordcounter
      if not p is nothing then
          p!progresstext = "Show whatever you want - eg Processing record " & recordcounter & " of " & totalrecords
     end if           
wend
msgbox "show results etc"

'now close the progress form
if not p is nothing then
    docmd.close acForm, "frmProgress"
    set p = nothing 'we need to clear this now, as p is on longer open. 
end if
 

TheSearcher

Registered User.
Local time
Today, 03:23
Joined
Jul 21, 2011
Messages
304
Thanks Gemma. I appreciate you taking the time to show me this!
 

Users who are viewing this thread

Top Bottom