Navigation Form with Ease (1 Viewer)

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:21
Joined
May 7, 2009
Messages
19,231
hello to all!

does Navigation Form gives you a headache. when your standalone form is working properly and you can refer to any control with ease. then when you moved it inside the Navigation Form all your control references are now invalid.:confused:

forms![Navigation Form]!mySubform1!TargetSubform.Form.yourControl

the above codel not work!?

hope is not lost at all and there is an easy way to go around this problem.

you see Forms and Reports are all Classes. a class can have many functions, procedures and properties (public and privates).

say on the above example (TargetSubform), you want to expose the value of your textbox( ie, txtTextName) and you want it to be accessible to any other subform inside the Navigation Form, including the Navigation form.

all you have to do is open the TargetSubform in form design and create a Public Function or Get Property in TargetSubform:

Public Property Get GET_TextName() As Variant
GET_TextName = Me.txtTextName
End Property

or

Public Function GET_TextName() As Variant
GET_TextName = Me.txtTextName
End Function

save the form and your done.

now go to the VBE and notice your TargetSubform class there, the one preceeded with "Form_".

to retrieved the value of your txtTextName control on TargetSubform in any subform within Navigation Form:

yourTargetControl = Form_TargetSubform.GET_TextName()

or

MsgBox "" & Form_TargetSubform.GET_TextName()

now its time for you to try it on your dreaded Navigation Form.
happy coding to all:)
 

spikepl

Eledittingent Beliped
Local time
Today, 13:21
Joined
Nov 3, 2010
Messages
6,142
One has to take great care using your method, especially while debugging.

Because if the main form is closed, so is the subform. But using the reference Form_TargetSubform.GET_... will cause the subform itself to open but invisibly, which may have some consequences.

I once spent a week debugging code and couldn't make things fit, until I was told that invisible instances of a form were floating in the background screwing everything up :D
 
Last edited:

spikepl

Eledittingent Beliped
Local time
Today, 13:21
Joined
Nov 3, 2010
Messages
6,142
Attached is an A2010 db. OPen it, press the button. It calls your code which opens the subform (I make the subform explicitly visible on load).
 

Attachments

  • Test of ease.accdb
    500 KB · Views: 114

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:21
Joined
May 7, 2009
Messages
19,231
I once spent a week debugging code and couldn't make things fit, until I was told that invisible instances of a form were floating in the background screwing everything up

even with it loaded, you can still have as many same form loaded, and it is a class we are talking here, encapsulated codes.

besides we are deliberately Getting a value, what is the worst of that.
 

spikepl

Eledittingent Beliped
Local time
Today, 13:21
Joined
Nov 3, 2010
Messages
6,142
I do not understand your comment but never mind that.

If you know what you are doing then fine. If not, as most readers here, beware of a syntax that causes closed forms or subforms(by themselves!) to open without telling.
 

jepoysaipan

Registered User.
Local time
Today, 21:21
Joined
Nov 4, 2007
Messages
133
ok here's a present scenario I am right now, I didn't bother yet to try the code pardon @arnelgp, like you said everything works well when I use the standalone forms with tab control, but when I plugged it on a navigation with (horiz & vert left config) it gives me the dreaded error.

I have tried msgbox [Forms]![frmMain]![frmNavigation].Form![SalesAmount]
[Forms]![frmMain]![frmNavigation]![navButton].Form![SalesAmount]
[Forms]![frmMain]![frmNavigation]![navButton]![SalesAmount]

SalesAmount is a field located in a form called frmSales
frmSales is the Navigation Target Name for the Button "Record Sales" (Top Nav)
"Record Sales" is activated when clicked the "Sales" (Left Vert Nav)
frmNavigation is the name of my Navigation Form inside my frmMain

another thing is inside the frmSales there is a subform called frmSalesDetail and I also want to reference some fields

Hope I've picked your minds about this.

Thanks in advance!
 

Users who are viewing this thread

Top Bottom