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"
Related
I have a form called Workbench. Within that form is tab control with a sub form called "sup_contacts_info" with a control called cmb_contacts. Now I know that tabs are ignored when retrieving values from a control within a form embedded within. That said, I know that this parameter works for my pulldown control.
[Forms]![Workbench]![sup_contacts_info].[Form]![cmb_contacts]
Now within the sup_contacts_info sub-form is yet another sub-form called sup_subform_contact_cards and a control called txt_sc_owner_id. I want the default value of this control to equal that of [Forms]![Workbench]![sup_contacts_info].[Form]![cmb_contacts]
I tried
[Forms]![Workbench]![sup_subform_contacts_cards].[Form]!txt_sc_owner_id.DefaultValue = [Forms]![Workbench]![sup_contacts_info].[Form]![cmb_contacts]
Access complains that it cannot find the control. I've tried:
[Forms]![Workbench]![sup_contacts_info].[Form]![sup_subform_contacts_cards].[Form]!txt_sc_owner_id.DefaultValue
..to go from the sub-form to the sub-sub form but had no luck (perhaps I'm missing something)
I think it may be the way I am trying to a sub-form control, to what I think is a sub-sub control. What is cleaner (or shorter) way to make this call.
Where #1 is the parent form (workbench), #2 is the sub-form (sup_contacts_info) with the combo-box pulldown, and #3 is the sub-sub-form (sup_subform_contact_cards) with the text box (txt_sc_owner_id) whose default parameter I want to equal that of the combo-box pulldown.
Thanks
Mapping to Me.Parent.cmb_contacts was a huge help!
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
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.
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.
I need to create my own "navigation" form in Ms Access. Basically, I have a MAIN form that has one field named LotNumSelect
Then, buttons representing each form the user would like to view.
Button1 - Customer
Button2 - Job Data
etc.
Once the customer clicks a button, the procedure would open the corresponding form in the subform window to the record matching the LotNumSelect field.
So far, I have this.
Private Sub ContactInfo_Click()
Main_Customer_Sbfm.SourceObject = "Main_Customer_Sbfm"
Forms!Form1!Main_Customer_Sbfm.Form!Lot_Number.SetFocus
This nicely switches the form within the subform. the problem is how do I get the form within the subform find the record associated with the data in the LotNumSelect Field?
I tried this..
DoCmd.FindRecord LotNumSelect.Value, acEntire, , acSearchAll
but it's giving me a runtime error of "2162"
"A macro set to one of the current field's properties failed because of an error in a FindRecord action argument.