DB-Structure:
My database contains multiple questionnaires. Each questionnaire have a form dragged as subforms into seperate tabs of a Navigation Form called frmNavigation. Mind it is the new Navigation Form feature which first appeared in Access 2010, and not the old Tab Control. The reason why I don't use the normal Tab Control, is that it cannot automatically resize the tabs according to the different sizes of questionnaire-forms / subform. That is why I see the Navigation Form feature as a more cosmetic viable feature than the older tabbed panes, and so far it has been very simple to use. It is also possible to have two horizontal levels of tabs with the Navigation Form, which I have used to arrange my many subforms into categories (Visit 1, Visit 2, Visit 3, Visit 4).
The default window shown is frmSearch, which contains a multiple search form, to search between subjects in a list box. When clicking on a record in the list box (SSN being the unique identifier between tables), this code runs:
Code:
Private Sub SearchResults_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmNavigation"
stLinkCriteria = "[SSN]='" & Me.SearchResults & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "frmSearch"
End Sub
Problem:
The above code works so far as to open frmNavigation, and show the correct record in some fields I have included in the header. But the different subforms in the NavigationSubform Control just defaults to the first record, and not the one handpicked in frmSearch. Maybe I can link the subforms to the locked, and read-only field "SSN" in the header of frmNavigation? Both the control NavigationSubform (shared control for all subforms) and the buttons/tabs for all the subforms, eg. navVisit1Crf1, have events called "On Enter", and all the panes/tabs have "On Click". They even have a data control called "Navigation Where Clause", but I am struggling to get any code working. And yes I am very much a beginner in the world of Access.
I tried this code in the data control "Navigation Where Clause":
Code:
DoCmd.BrowseTo acBrowseToForm, "frmVisit1Crf1", "frmNavigation.NavigationSubform", "[SSN]='" & Me.SSN & "'"
But it did not work. Do I also need a SSN-field (locked and invisible, like the one in the header of frmNavigation) on the subform frmVisit1Crf1?
My database is too large (2 mb) for upload, but you can get it here