Navigation SubForm with a Navigation SubForm, VBA references

kajtam

Registered User.
Local time
Yesterday, 18:17
Joined
Feb 28, 2014
Messages
11
Hi all,

its day two of my struggle. I am trying to find a solution and its just driving me mad. Here is my situation:

frmsubfrm.jpg



Now Here is a piece of my code:

1) Establishing Temp Vars and opening the form (frmEditProject):
Code:
    Dim stDocName As String
    Dim stLinkCriteria As String
    Dim stLinkCriteria2 As String
    Dim tmp As String
 
    tmp = [SearchResults].[Column](12)
    stDocName = "frmEditProject"
    stLinkCriteria = "[ProjectGPN]=""" & Me![SearchResults] & """"
    stLinkCriteria2 = "[EnquiryNo]=""" & tmp & """"
    TempVars.Add "CurrentEnquiryNo", stLinkCriteria2
    TempVars.Add "ProjectGPN", stLinkCriteria
    DoCmd.OpenForm stDocName

2) Opening the form frmProjectInfo to a record based on tempVar![ProjectGPN]:
Code:
Private Sub Form_Load()
DoCmd.BrowseTo ObjectType:=acBrowseToForm, _
ObjectName:="frmProjectInfo", _
PathToSubformControl:="frmEditProject.NavigationSubform", _
WhereCondition:=TempVars![ProjectGPN], _
Page:="", _
DataMode:=acReadOnly
End Sub
3) Opening the form frmEnquiryNav to a record based on temvar![EnquiryNo]:
Code:
Private Sub NavigationButton7_Click()
DoCmd.BrowseTo ObjectType:=acBrowseToForm, _
ObjectName:="frmEnquiryNav", _
PathToSubformControl:="frmEditProject.NavigationSubform", _
WhereCondition:=TempVars![CurrentEnquiryNo], _
Page:="", _
DataMode:=acReadOnly
End Sub
4) and now that the part I have problems with (not for the first time, last time I just changed the design). frmEnquiryNav is a Navigation form with Subforms obviously. I would like to navigate to specific record related to the project, based on the EnquiryNo. My code is in different variants (here seen for different subforms), none of it is working:

Code:
Private Sub frmEnquiryCustomer_Click()
DoCmd.BrowseTo ObjectType:=acBrowseToForm, _
ObjectName:="frmEnquiryCustomer", _
PathToSubformControl:="frmEditProject.Form!frmEnquiryNav!NavigationSubform", _
WhereCondition:=TempVars![CurrentEnquiryNo], _
Page:="", _
DataMode:=acReadOnly
'Me!Subform1.Form!Subform2.Form!ControlName
End Sub
Private Sub frmEnquiryDetails_Click()
DoCmd.BrowseTo ObjectType:=acBrowseToForm, _
ObjectName:="frmEnquiryDetails", _
PathToSubformControl:="Forms!frmEditProject!NavigationSubForm.Form!NavigationSubform", _
WhereCondition:=TempVars![CurrentEnquiryNo], _
Page:="", _
DataMode:=acReadOnly
'Forms![main form name]![subform control name].Form![nested subform control name].Form![control name]
'Forms!frmMain!Subform1.Form!Subform2.Form.
End Sub
Private Sub frmEnquiryInfo_Click()
DoCmd.BrowseTo ObjectType:=acBrowseToForm, _
ObjectName:="frmEnquiryInfo", _
PathToSubformControl:="frmEnquiryNav.NavigationSubform", _
WhereCondition:=TempVars![CurrentEnquiryNo], _
Page:="", _
DataMode:=acReadOnly
End Sub

I am not sure if im working from the main form, or the sub form, should I be addressing it in an absolute or relative way, where should I start?

I have tried to make sense of it using those site:
http://www.btabdevelopment.com/ts/ewtrhtrts
http://ss64.com/access/syntax-references.html
http://access.mvps.org/access/forms/frm0031.htm

Both Control Names are "NavigationSubform".

I like my keyboard, please don't let me break it :banghead:
 
A piece of advice: discard the expression "not working" from your dictionary. It is a BS-term signifying that you are unhappy, and nothing else. Read my signature.

AS to how to refer to things: on the form on which yuo wish to refer to a control on another form, add a textbox. In the ControlSource property of that box, click the ellipses and choose the expression builder. Navigate to the desired control on the desired form, click OK (or perhaps Paste) and now you have a syntactically correct expression referrign to the desired control.
 
Thanks spikepl, your advice didn't help me that much, but I did some more experimenting on my own and came up with a solution:

Code:
Private Sub frmEnquiryDetails_Click()
DoCmd.BrowseTo ObjectType:=acBrowseToForm, _
ObjectName:="frmEnquiryDetails", _
PathToSubformControl:="frmEditProject.NavigationSubform>frmEnquiryNav.NavigationSubform", _
WhereCondition:=TempVars![CurrentEnquiryNo], _
Page:="", _
DataMode:=acReadOnly
End Sub

Now, it seems the problem is with that I don't quite understand the difference between ! and . and > operators in path syntax.

If anyone could provide some link or a simple answer, I would be very grateful.
 

Users who are viewing this thread

Back
Top Bottom