How do I keep forms maximised in MSAccess Applications - ms-access

I have an app with about 40 screens that can all be called in various orders.
I have DoCmd.Maximize on the OnActivate function of every form but when you close a form that is in the foreground the form behind it is back to it's "designed" size. When you then click on the form it activates it and makes it run the DoCmd.Maximize code.
How do I get the whole app to just run full screen?

In Access 2010, you can use File->Options->Document Windows Options->Tabbed Documents, you can set the size of the form to the maximum allowed and remove auto sizing, or you can add code to the close button to maximize the next form.
Forms(Forms.Count - 2).SetFocus
DoCmd.Maximize
Forms.Count -1 is the current form and -2 is the form behind.

Related

MS Access challenge with opening form at specific location on dual monitors

I have an Access 365 application with a main form and multiple modal pop-up dialogs. I'm reading the .WindowLeft and .WindowTop properties of the main form in conjunction with the .Move method in the Form_Load code in the pop-up to place the dialogs where I want them (at a fixed offset, to the right and down, so the pop-ups are always over the main form).
This works fine on the main screen of a dual monitor system where the screens are used as an Extended Display. When I drag the main form to the right onto the second monitor, it continues to work as expected until I get too far to the right. It appears that the maximum twip value for WindowLeft = 32760 (on my 1920x1080 monitors, anyway). If WindowLeft on the main form + the fixed offset for my dialogs exceeds this value, I get overflow errors when the dialog tries to open. If I keep dragging the main form to the right, WindowLeft starts returning negative values, and those start moving back toward zero as I continue to drag the form further to the right. It's like the "anchor point" for WindowLeft shifts.
Since my goal is to open my modal dialogs at a predictable position regardless of the main form's position, once I understood this behavior, I thought I could code around it by adjusting my offset if the main form WindowLeft is < 0. That works in theory, but it means the code wants to .Move the dialog to a negative value (say, -20000 twips or so). This doesn't cause an error, but the dialog just won't display when I do that. If I Alt-Tab, Windows thinks it is open, but it isn't visible. I've tried .Repaint, .SetFocus, and .Visible = True to try to give it a kick in the pants so it will display, but without success.
Has anyone run into this before? If so, how did you handle it?

Continuous form height - Too tall

For some reason my continuous form is nearly as long as my screen, even when I only have a few records. In design view, I can see that the detail section is supposedly only .333" so I'm not sure what is causing this. I'd prefer that the form size be dynamic, but would also settle for a static height at this point. Just want something less obnoxiously large. Anyone know a reason this might be happening and how to fix it?
Open the form in design view. Set the forms border style to “sizable”. You don’t have to, but I would also in the format tab set auto size = no, fit to screen = no.
Now flip the form into regular view. At this point, re-size the form to as you want. Now hit ctrl-s, and close the form.
You can now re-launch the form, and you see the size you set sticks. However, because the border style is “sizable”, then users can re-size the form. If you don’t want this to occur, then open form in design view (after close and doing above steps). Now change the border style to “thin” and close the form. (Answer yes to save).
At this point, when you launch the form, your sized settings will stick, and you (and users) cannot re-size the form.
If you need to change the size, then simply follow the above steps again. Thus open in design view, set border type to sizeable, flip into regular form view. Size the form as desired, and then hit ctrl-s to “save/freeze” the size. As noted, change the border style back to thin if you wish to prevent users etc. from being able to re-size the form.
Open the form in design view, adjust the window hight as desired and click "save" to save the changes. When just closing the form, Access doesn't see that something has changed.
Added:
To illutrate what I mean (after changing the database to use "Overlapping Windows"), here are some screenshots.
Tall window:
Adjust the hight as desired:
Switch to design view of the shortened form (for example by right-clicking the header):
Now, save the form, close it an re-open:
The AutoResize property ensures that no "half detail rows" will be dieplayed when opering the form.

Prevent 'save design changes' for an open form when closing Access

I have a split form as my main interface in an Access 2010 application. As normal, users are able to resize the datasheet portion, reorder columns, etc.
However, I don't want them to save such changes when leaving the form. Each time the form is opened the default format should be loaded.
I've taken care of all but one closing method. To avoid them closing using the default close button I've set Border Style = None. Instead I have a Close Form button that uses DoCmd.CLOSE acForm, "Main_form", acSaveNo
But if the user clicks the close button for the Access application, it pops the 'Do you want to save changes to the design of form` dialog like always.
I looked into disabling the application's Close button, but messing with Windows API is beyond my skill (and there should be a way to accomplish this without going to extreme measures).
I found a way to do this. A combination of database options, form format options, and vba can do it.
Go to the 'Current Database' options screen in the main Access
options and uncheck 'Enable design changes in Datasheet view'. This will prevent all datasheet view design changes in the database, so you will have to go into design mode for any table changes. Users can still reorder and resize columns within a form, but Access no longer considers that a valid design change and will not prompt to save it no matter how you close the form
Set the form format property 'Save Splitter Bar Position' = No. The form will now clear any change to the bar location when the form is closed. Access got really weird on me about this setting, however. Once I had ever set the option to no, I could no longer use design view or layout view to set a new default bar position; it always reverted to the location where it was when I first tried this setting. Even resetting the option to Yes, saving the design change, and fully exiting the database did not fix this.
So I added an On Load event to reset the split form size when the form opens: Me.SplitFormSize = 9000. The numbers involved are surprisingly high; in the form properties list this is set in inches. Mine was 6.5", which apparently translates to 9000.
With these three changes (along with the steps I detailed in the question) Access no longer prompts to save design changes when the form is closed, even if the user is closing the Access application entirely. The form also snaps the split form bar back to where it should be on load.
Since the API is beyond my skill too, here is a left-field workaround.
Duplicate Main_Form and rename it "Main_Form_Template". Create an Autoexec module or edit an existing one and add:
DoCmd.DeleteObject acForm, "Main_Form"
DoCmd.CopyObject , "Main_Form", acForm, "Main_Form_Template"
That should reinstate the standard template for the user each time they open the database even if they were to save the form when closing Access.
Turn your close button off on the form.
On the form's property sheet, format tab, about 2/3 of way down. Set Close Button = No
This forces the user to close it via the button you created.

Forms calling reports in access

Step1: I open an Access form when the software opens. It acts like a switchboard manager where the user can open other forms and reports. (Popup = yes, modal = no)
Step2: Click to open a "Master Form" which also has other options. (ditto) So the original VB code called this form to be open and is still "running" in the background.
Step 3: Click to open a report based on the record selected.
So now there's 2 forms open and 1 report. User cannot toggle between them, must close one to get to the other (necessary).
On the open report, I would like to modify the rightclick commandbar. However, "Close" doesn't work because Access now shows Form1 and Form2 above as gray and Access is locked. I would like to be able to right-click to do a number of things including Close, Change to Design View, etc. But if I'm locked out like this, none of these will work.
I searched on...
1. Ending the background vba that's running - no luck
2. Setting focus on the active screen name - no luck
3. Setting focus on a control on the Form2 above - no luck
4. Tried all kinds of CommandBar things, no luck (ID choice vs. manual OnAction) and many more
I'd be happy to attach what I'm doing but it's pretty big, although I could probably cut out the sections that this applies too...
I've been searching for about 16 hours now... Anyone???
Thanks so much.
Popup = Yes in Access means two things:
The form or report stays above all other forms and reports that have Popup = No and above Access’ application window.
The form or report is not bound to the area of Access' application window and can be drawn outside of it.
You have two options:
Set Popup = No for the two forms. In this case they will be tied to the application window area.
Set Popup = Yes for the report as well, so that it can stand in front of the two forms.

Phantom boxes in an Access 2007 form when viewed in Access 2010

I have an Access db (developed in Access 2007) set to display windows in tabbed view. It opens with a simple form to show the user various options. Since I made it, we upgraded to Access 2010.
Since this form was made for navigation to other forms (there is no underlying data set), it just has buttons in the Form Header that open other forms. Here's sample code from one of those buttons:
Private Sub Cmd_Lookup_Click()
DoCmd.OpenForm "Frm7a_Lookup"
End Sub
However, when these buttons are clicked, a dotted rectangle (about 1-2 inches in length and width) appears in the upper left of the form while the new form is loading. I have no idea where this 'phantom box' is coming from. There's no object in that area of the form and all the other objects in the form are visible and accounted for. So, there's nothing for me to delete.
It's visually unappealing and shouldn't exist. How do I make this phantom box go away? Do I have to rebuild the form from scratch?
The phantom boxes seem to appear when buttons (perhaps with pictures) from previous versions are on the form.
Try removing the buttons and re-adding them.