Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 01-02-2018, 10:50 AM   #1
daryll
Newly Registered User
 
Join Date: Jan 2018
Posts: 43
Thanks: 18
Thanked 1 Time in 1 Post
daryll is on a distinguished road
Exclamation How to reference a sub-subform in a navigation form from outside form

What is the appropriate path to reference a sub-subform in a navigation form from outside form. This path work if you are in the navigation form, but not on outside form.

Code:
Forms![Nav Form Attachment]![NavigationSubform].Form.[Pool eFile Attachment].visible=True

daryll is offline   Reply With Quote
Old 01-02-2018, 11:14 AM   #2
Ranman256
Newly Registered User
 
Join Date: Apr 2015
Location: KY,USA
Posts: 3,393
Thanks: 0
Thanked 753 Times in 736 Posts
Ranman256 will become famous soon enough Ranman256 will become famous soon enough
Re: How to reference a sub-subform in a navigation form from outside form

the BUILDER will provide you with the correct path.
(use a query to paste the path in)

yours looks correct.
Ranman256 is offline   Reply With Quote
Old 01-02-2018, 11:18 AM   #3
daryll
Newly Registered User
 
Join Date: Jan 2018
Posts: 43
Thanks: 18
Thanked 1 Time in 1 Post
daryll is on a distinguished road
Re: How to reference a sub-subform in a navigation form from outside form

I'm not familiar regarding "the BUILDER or use a query to paste the path". Kindly explain further.

daryll is offline   Reply With Quote
Old 01-02-2018, 04:19 PM   #4
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 28,370
Thanks: 15
Thanked 1,617 Times in 1,535 Posts
Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all
Re: How to reference a sub-subform in a navigation form from outside form

Quote:
What is the appropriate path to reference a sub-subform in a navigation form from outside form. This path work if you are in the navigation form, but not on outside form.
The Navigation form is a special purpose form and it works differently than you might expect. The nav form uses a SINGLE subform control. As you click navigation buttons, a different form gets loaded into the control. That means that ONLY the currently active subform is ever available. But, you would address it as you would address ANY subform.

Forms!yournavformname!thesubformcontrolname.Form!y oursubofrmfieldname

"thesubformcontrolname" is static. It is ALWAYS the Name property of the subform control REGARDLESS of what form got loaded into the subform.
__________________
Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
Old 01-02-2018, 08:22 PM   #5
daryll
Newly Registered User
 
Join Date: Jan 2018
Posts: 43
Thanks: 18
Thanked 1 Time in 1 Post
daryll is on a distinguished road
Re: How to reference a sub-subform in a navigation form from outside form

@Pat Hartman
Code:
Forms!yournavformname!thesubformcontrolname.Form!y
This example you've given me would not work. As i've tried interchanging "! and ." prior posting here. I was googling with regards to this but all examples are referred inside the navigation form like my code posted above.
daryll is offline   Reply With Quote
Old 01-02-2018, 09:17 PM   #6
Galaxiom
Super Moderator
 
Join Date: Jan 2009
Location: NSW Australia
Posts: 11,763
Thanks: 118
Thanked 1,546 Times in 1,451 Posts
Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold Galaxiom is a splendid one to behold
Re: How to reference a sub-subform in a navigation form from outside form

Quote:
Originally Posted by daryll View Post
What is the appropriate path to reference a sub-subform in a navigation form from outside form. This path work if you are in the navigation form, but not on outside form.

Code:
Forms![Nav Form Attachment]![NavigationSubform].Form.[Pool eFile Attachment].visible=True
That reference is in the context of the Application and refers via the Forms Collection. If it works inside the form it should work outside the form.

If a multilevel reference throws an error I usually beak it down and try it piece by piece from the Immediate Window using the Name property which all these objects have.

Code:
? Forms![Nav Form Attachment].Name
 
? Forms![Nav Form Attachment]![NavigationSubform].Name
 
? Forms![Nav Form Attachment]![NavigationSubform].Form.[Pool eFile Attachment].Name
First one that breaks is where to start looking for the problem.

BTW I strongly recommend you discontinue using spaces in object names.
Galaxiom is offline   Reply With Quote
The Following User Says Thank You to Galaxiom For This Useful Post:
daryll (01-03-2018)
Old 01-03-2018, 07:57 AM   #7
daryll
Newly Registered User
 
Join Date: Jan 2018
Posts: 43
Thanks: 18
Thanked 1 Time in 1 Post
daryll is on a distinguished road
Re: How to reference a sub-subform in a navigation form from outside form

@Galaxiom
That would be a great hint. I'll try your suggestion

daryll is offline   Reply With Quote
Old 01-03-2018, 08:46 AM   #8
daryll
Newly Registered User
 
Join Date: Jan 2018
Posts: 43
Thanks: 18
Thanked 1 Time in 1 Post
daryll is on a distinguished road
Re: How to reference a sub-subform in a navigation form from outside form

Now I spotted the problem. Just to share my experience, which is i know some people may find it obtuse. Anyway.

My navigation form has a two tabs and this form is designed to pop-up once the user click on a control (i.e. textbox) which I set the on click event on it. I noticed that when you refer a subform which belongs to the first tab it doesn't throw any error. Which means that the path I posted above is valid. For the sake of clarity this is the path of the subform.
Code:
Forms![Nav Form Attachment]![NavigationSubform].Form.[Pool eFile Detail].visible=True
However, when you refer a subform that belong to the second tab using the same pattern i.e
Code:
Forms![Nav Form Attachment]![NavigationSubform].Form.[Pool eFile Attachment].visible=True
it throws an error "can't find field |1 referred to your expression" but if you navigate to the second tab without closing the Navigation Form and again clicking on the control (i.e textbox) which is on the main form then that path is valid.

So my question now, how can I make the path on which the form will not throw any error?

Last edited by daryll; 01-03-2018 at 08:53 AM.
daryll is offline   Reply With Quote
Old 01-03-2018, 09:41 AM   #9
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 28,370
Thanks: 15
Thanked 1,617 Times in 1,535 Posts
Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all
Re: How to reference a sub-subform in a navigation form from outside form

Quote:
it throws an error "can't find field |1 referred to your expression" but if you navigate to the second tab without closing the Navigation Form and again clicking on the control (i.e textbox) which is on the main form then that path is valid.

So my question now, how can I make the path on which the form will not throw any error?
I gave you the answer:
Quote:
The Navigation form is a special purpose form and it works differently than you might expect. The nav form uses a SINGLE subform control. As you click navigation buttons, a different form gets loaded into the control. That means that ONLY the currently active subform is ever available. But, you would address it as you would address ANY subform.
That means that you CANNOT reference a form that is not loaded. Period!!! If tab1 is active, NOTHING on any other tab can be referenced.

If this is a problem for you then you cannot use a navigation form. You will have to build your own which is what we did for almost 20 years before MS decided to "help" us with a new form type that doesn't work (nor should it) like the forms we used to design ourselves. The navigation form works this way because it is intended to be a menuing system and so manage a large number of other forms. The main form would simply be too "heavy" and therefore clunky and slow if all the forms were always loaded. The decision was made to load only the active form. This works in the vast majority of cases. It is only when one form is related to another that the method fails.

You might be able to solve the problem by making your form a tabbed form. That way, both forms will be loaded into the nav subform control and therefore both can be referenced..
__________________
Bridge Players Still Know All the Tricks

Last edited by Pat Hartman; 01-03-2018 at 09:48 AM.
Pat Hartman is offline   Reply With Quote
The Following User Says Thank You to Pat Hartman For This Useful Post:
daryll (01-03-2018)
Old 01-03-2018, 11:42 AM   #10
daryll
Newly Registered User
 
Join Date: Jan 2018
Posts: 43
Thanks: 18
Thanked 1 Time in 1 Post
daryll is on a distinguished road
Re: How to reference a sub-subform in a navigation form from outside form

Quote:
Originally Posted by Pat Hartman View Post
I gave you the answer:
That means that you CANNOT reference a form that is not loaded. Period!!! If tab1 is active, NOTHING on any other tab can be referenced.
I didn't get your point clearly nor paying attention to it. May be I was too carried to receive an answer seeing a code directly. And beside, this is my first project with MS Access.

Your warning was right I really didn't expect it behaved that way. Anyhow, now you've explained it directly it really gave me a clear insight. Thanks @Pat Hartman

One more thing, by using docmd.browseto prior to initiating the subform path will it solve the issue?

Last edited by daryll; 01-03-2018 at 11:56 AM.
daryll is offline   Reply With Quote
Old 01-03-2018, 11:52 AM   #11
daryll
Newly Registered User
 
Join Date: Jan 2018
Posts: 43
Thanks: 18
Thanked 1 Time in 1 Post
daryll is on a distinguished road
Re: How to reference a sub-subform in a navigation form from outside form

Quote:
Originally Posted by Pat Hartman View Post
You might be able to solve the problem by making your form a tabbed form. That way, both forms will be loaded into the nav subform control and therefore both can be referenced..
Did you mean a subnavigation form of the current nav form? Or may be not.
daryll is offline   Reply With Quote
Old 01-03-2018, 06:27 PM   #12
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 28,370
Thanks: 15
Thanked 1,617 Times in 1,535 Posts
Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all
Re: How to reference a sub-subform in a navigation form from outside form

No. I meant what I said - a form with a tab control on it. You can have separate subforms on each tab page if that will solve your problem. Since it is NOT a navigation form, you CAN have multiple forms loaded at the same time. Of course without knowing more about WHY you need to reference one form from another, we really can't be much help.

Just remember, a subform on a subform is one level deeper you'll need additional stanzas in your Forms!.... reference to get down to the subform.
__________________
Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
Old 01-03-2018, 10:03 PM   #13
daryll
Newly Registered User
 
Join Date: Jan 2018
Posts: 43
Thanks: 18
Thanked 1 Time in 1 Post
daryll is on a distinguished road
Re: How to reference a sub-subform in a navigation form from outside form

This trick solve the issue.

In order to not let the form throw an error, first execute the docmd.browseto (browse to second tab) prior to
Code:
Forms![Nav Form Attachment]![NavigationSubform].Form.[Pool eFile Attachment].visible=True
.
daryll is offline   Reply With Quote
Old 01-04-2018, 12:00 PM   #14
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 28,370
Thanks: 15
Thanked 1,617 Times in 1,535 Posts
Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all
Re: How to reference a sub-subform in a navigation form from outside form

Glad it worked for you.

__________________
Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
Reply

Tags
msaccess , vba access 2010

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reference a field on subform of navigation form (access 2010) liddlem Queries 2 12-12-2018 05:51 AM
[SOLVED] Reference Subform of Navigation form bconner Forms 3 12-11-2017 12:21 PM
Embed A Navigation Form Instead Of Using Tabs (navigation Form As Subform) jerem Forms 3 10-22-2014 06:00 PM
parameter reference in navigation form hockey8837 Forms 4 12-29-2013 11:22 AM
Navigation Form Subform - Reference in Macro Holly_Associated Forms 0 08-22-2013 12:20 AM




All times are GMT -8. The time now is 01:43 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World