Forms calling reports in access - ms-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.

Related

Why MS Access pop up form doesn't regain focus after switching apps with Alt-Tab?

I have an Access 2016 application that opens a pop-up form when user double-clicks on a record in a datasheet form. That's meant to be a 'detail form' showing all fields in record (datasheet shows only a few). Now, while editing data on popup form, I switch to another app (say Notepad) to copy some text from there or simply check some other thing. I then switch back to Access app by applying Alt-Tab. However, now focus is over datasheet form, instead of pop up form it was when I first switched to Notepad.
Can anyone please help on understanding why this happens? Ultimately I want to return focus over popup form whenever I switch back from any other app by using Alt-Tab, i.e., maybe by detecting in VBA when Access application gets focus back so I can set focus on desired form. I've read some suggestions about using some Windows API function but no detailed examples on that.
Any help will be greatly appreciated.

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.

MS Access Tab control in different locations on form for different users

I have a MS Access database with a number of forms. The back end seems to be working just fine, but the forms are causing me some trouble. When I open them, they look fine, but when coworkers open them, the Tab Control is in a different location, and on top of other controls. This is bad from a functional and aesthetic perspective. I have another form where this doesn't seem to be the case, and I'm not sure what is different. How can I lock down the location of the Tab Control so it doesn't appear in different places for different people?
This is how it looks on my computer:
This is how it looks to others - the Tab Control is shifted up:
Put the tab control in a container such as a panel and assign a location to the container.

Run VBA code whenever a tabbed form is reselected in Access

EDIT: For clarification, I'm talking in the below post about tabbed document browsing, not a Tab Control. However, if you're looking for roughly the same problem but regarding a Tab Control, Gord Thompson's answer is correct. Two answers for the price of one!
I've got an Access 2007 database that uses tabbed documents. I need to run some VBA code every time a user selects the form called "Reports", either via opening it or clicking on its tab if it's already open.
I could achieve much the same thing by closing it each time it's used and running the code on an OnLoad event, but ideally I'd like to keep it open so that users can keep the settings of the various drop down boxes, radio boxes etc that they've already set on "Reports".
I was hoping for an event that could run code on tab reselection, but neither of my guesses (OnCurrent and GotFocus) seem to work (OnCurrent works only when the form is opened, like OnLoad would).
Any ideas greatly appreciated - can't find what I'm looking for on Google, though I suspect that's because I don't know exactly what I'm looking for.
The .Value property of a TabControl returns the index (zero-based) of the current page. So, if I have a TabControl named TabCtl14 that contains two pages, FirstPage and SecondPage, then the code...
Private Sub TabCtl14_Click()
If Me.TabCtl14.Value = 1 Then
MsgBox "SecondPage was clicked."
End If
End Sub
...displays the MsgBox whenever I click the "SecondPage" tab in the TabControl.
Have found the answer I was looking for. It's the OnActivate event.

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.