Open a Form as a SubForm - forms

On a GUI based on forms, I try to open and close some forms in order to do calculations.
I want to do it only with Access macros (for easier maintenance by non-technical personnel).
The problem is not to open and close the forms, I've found a way to do this with:
Close Window
ObjectType
ObjectName
Save: With Confirmation
OpenForm
Form Name: destinationForm
Display
Filter Name
Where Condition
Data Mode
Window Mode: Standard
But when the forms are part of bigger form (that I called Layout for explicit reasons), this macro close the main form and open destinationForm as a new one.
I know this behaviour is perfectly normal, but I haven't found marcos closing subform and opening other ones yet, or, even easier, changing Object Source of the subform object of my Layout form.

A Form is opened in Access as a sub form, if the SourceObject of a SubForm Control is set to it, and the parent form is loaded. So there is actually no such a thing as opening or closing a sub form.
Use SetProperty Macro Action to either set SubForm's IsVisible property, or it's SourceObject Property.
You could also use a Tab Control.

Related

Mapping parameters from embedded form within a form MSACESS

I am trying to get a query to update based on a value passed from a combo box within the same form. After I moved the form into a tabbed control box within another form it seems to have broken. I've tried mapping from the outer form to the combo box and still an error to provide parameters into the query.
The Outermost form is "workbench"
The tab control is "tabbed_space"
The inner form is "software_list"
The combo box is "cmb_server_selection
I have in the query
=[Forms]![workbench]![tabbed_space]![software_list]![cmb_server_selection]
What am I doing wrong?
Tab controls do not affect the "navigation path" of objects, the objects are still directly on their form.
To get objects on a subform, you need SubformControl.Form!Object
So it should be
=[Forms]![workbench]![software_list].Form![cmb_server_selection]
Note: this is easier to debug in the Immediate Window (Ctrl+g) than in the query (the form must be open of course) :
? Forms!workbench!software_list.Form!cmb_server_selection

Microsoft Access Where Condition doesn't works in a subform

I built a form called: "clientlist":
I put a macro with where condition on click:
="IDclient_logindata=" & [Maschere]![clientlist]![IDclient]
this means that when I click on an id client, access will open another form with the respective IDclient. For example if I click on IDclient 3:
it open another form called "client_logindata" filter to IDclient_logindata 3.
Then, I built a navigational form:
using clientlist as subform. But when I click a record, any record, it open every time the client_logindata form with IDclient_logindata form = 1, why it doesn' works in a subform?
Design View of "Navigation Form":
Solved in this way: ="IDclient_logindata=" & [IDclient]
When using a subform, references to controls need to be relative to the main form where the subform is treated as a child control.
Consider adjusting the conditional to the following structure. Do note this is the English version:
="IDclient_logindata=" & Forms!myMainForm!mySubform.Form!mySubformControl
Or specifically tailored to yours (be sure to get exact spelling of all objects):
="IDclient_logindata=" & Forms!NavigationForm!clientlist.Form!IDclient
The OP has found a working solution which is much simpler than what follows. However, I was still interested to see if we could get something on the original model to work, and I'd guess that for users attempting to achieve the same thing using VBA rather than embedded macro's the following may still be useful.
The issue with the code in the original question is that the relevant form isn't open at the 'top level' but as a subform.
Form "normal" subforms, you'd refer to the control on the subform like this:
Forms!navform!clientlist.form!IDclient
Where navform is the name of the outer form. Or in the generalised case, like this:
Forms!Mainform!Subform1.Form!ControlName
However, the "Navigation Form" Wizard, when dragging subforms onto the Add New tab in Layout view doesn't name the subforms nicely. So I had to code it this way:
Forms![Navigation Form]!NavigationSubform.Form!ControlName
To my surprise this code continued to work when I added further forms within the Navigation Forms tabs and had controls named the same as one in question. I guess NavigationSubform automatically points to the tab with the current focus.

Access Parent and subform open sequence

I have customized ribbons for each parent form. I need to set subform ribbon to be same with parent form.
I initiate ribbon on each forms and subforms on "Form_Load" routine. Parent form ribbon will be different for different user. I cannot hard code it on form property. On subform, I use Me.Parent.Form.RibbonName to get parent form ribbon name.
Me.Parent.Form.RibbonName is able to return parent form name. But, Subform "Form_Load" is trigged before parent form "Form_Load" is trigged. Me.Parent.Form.RibbonName will return null value.
Will it possible to control the load sequence between parent form and subforms? Parent form need to be loaded before any subforms are loaded.
Thanks.
The sequence is three-fold:
Subform loads
Main form loads
Subrom loads
So have code in the subform that disables any code when opened initially. Set a flag.
When opened next time, run your code and/or sets your variables.
Yes you can. Set the Subforms holders control source to "" Then in the on load or at some other event of the parent form set the subform control to your subform.
Me.subFormHolder.SourceObject = "subfrmYourSubformName"

CTRL+N Not invoking new on a DetailsFormTransactions Page

I need CTRL+N to invoke the default behavior, that is to create a new record without invoking my NewButton.
NewRecordAction property is not filled out, the shortcut does nothing, seems to be disabled.
The DataSource on the form allows create, I can create through my NewButton MenuItemButton.
I seem to have lost it's default behavior somehow, what could cause that?
Ctrl-N does not do anything, because the NewRecordAction is not filled out and because there is not a command button with New in the Command property.
I assume you have used "Create form from template" or have copied from the SysBPStyle_TransactionDetails form (same thing). This form contains a botton NewButton which is ment to call a creation form, like the SalesCreateOrder form.
You have two options:
Fill out the NewRecordAction with the control name of your create menu item. This should be mandatory in list pages.
Delete the NewButton, then create a new command button with New in the Command property. Also remember to assign a value to the DataSource property on the control or a containing node.
I personally prefer the second option (maybe combined with a setFocus call) because a create form is then not needed and there is only one form for you to maintain and the user to learn.

MS Access 2007 subform reload on formheader = visible?

I'm getting strange behavior in Access 2007 on a form designed in Access 2003.
I have an unbound main form with a data-bound subform. Within the Form_load of the main form, I set the subform sourceobject, which loads the subform recordset, etc. After the subform loads, but still within the Form_load of the main form, I set Me.FormHeader.Visible = True. After this line runs, for some reason the subform seems to close and reopen -- its Form_Unload fires, and it runs through its load process again.
Any idea why this would be happening? It's annoying, because its recordset is based on a parameter query, and the parameters get zapped when it reloads so it ends up prompting users for parameters.
Sometimes you have to live with (and work around) the behavior of MS Access, no matter how strange or annoying it is.
In this case I would probably advise that you move away from a parameter query and instead prompt the user for their input using VBA, store their input in a form level variable, and use that input to set the recordsource during the subform's Form_Load event. This way the user will only be prompted one time and never need to know that the form actually loaded twice.