Access 2010 - get NavigationSubForm Filter (1 Viewer)

Rudurk

New member
Local time
Today, 11:11
Joined
Jul 14, 2014
Messages
8
Hi,

I have reports inside my NavigationSubForm, and I would like to be able to print that report from a Print button in my Main Form

[Form layout] Main Form with ID combo & Navigation Control (Admin, Clinical, Prescriptions, etc) within Navigation control Admin is another Navigation control with all sorts of reports which get filter on the [ID Combo] in the [Main Menu (Parent Form)].

The problem is that is not the only filter some forms have filters for Dates between which are prompted on open.

So I tried to get the filters but annoyingly it does not return [ID] = '111021'.. it returns [ID] = Parent.Search

This is the code I used to get that filter

Code:
Me.NavigationSubform.Form.NavigationSubform.Report.Filter

I would like to get the solved Filter so i want [ID] = '111021' dates and stuff it seems to get fine because its prompted for.

I even tried making a function on the form that returns the filter, but it returns the same thing [ID] = Parent.Search

..... If we can't get the solved version of this filter then can we some how use Parent.Search and access would know what it's on about? coz Me.Controls("Parent.Search") Definitely doesn't work LOL

Thanks in advanced. I hope I there is a way to do this.. more often that not my questions are simply not doable, which annoys me :banghead:

Code:
Private Sub BTNPrint_Click()
    On Error Resume Next
    Dim tempReport As Report: Set tempReport = Me.NavigationSubform.Form.NavigationSubform.Report
    Dim tempStr As String: tempStr = Me.NavigationSubform.Form.NavigationSubform.SourceObject
    Dim CurrentReport As String
    
    If (tempStr Like "Report.*") Then
        CurrentReport = Replace(Me.NavigationSubform.Form.NavigationSubform.SourceObject, "Report.", "")
        DoCmd.OpenReport CurrentReport, , , tempReport.Filter
    Else
        MsgBox ("You can only print reports.")
    End If
End Sub

But obviously the above code doesn't work because when the report is opened for printing it's filter is ID = Parent.Search and because the report doesn't have a parent it prompts me asking me to enter Parent.Search


Edit.. Guess this is another question that cannot be done.. mmm do I leave the thread open ... or mark it as solved? Doesn't seem to have a Close thread button
 
Last edited:

Rudurk

New member
Local time
Today, 11:11
Joined
Jul 14, 2014
Messages
8
OK so, I came up with a crappy solution. Since I know what is likely to be in the filters.

Code:
Private Sub BTNPrint_Click()
    On Error Resume Next
    Dim tempReport As Report: Set tempReport = Me.NavigationSubform.Form.NavigationSubform.Report
    Dim tempStr As String: tempStr = Me.NavigationSubform.Form.NavigationSubform.SourceObject
    
    If (tempStr Like "Report.*") Then
        DoCmd.OpenReport tempReport.Name, , , Replace(Replace(Replace(tempReport.Filter, "Parent.Searcher", "'" & Me.Searcher & "'"), "Parent.vTBSD", "#" & Format(Me.vTBSD, "MM/DD/YYYY") & "#"), "Parent.vTBED", "#" & Format(Me.vTBED, "MM/DD/YYYY") & "#")
    Else
        MsgBox ("You can only print reports.")
    End If
End Sub

So I am just replacing the Parent.Searcher with the actual value obviously it only does it if it finds it so this works for any reports with or without dates... saves me trouble having to tell it which reports have dates and which reports don't.

... I am going to leave this thread open for a day and see if someone comes up with a better way then i'll close it as solved.
 
Last edited:

Users who are viewing this thread

Top Bottom