Solved Open a Report from a Form and pass the filter to the report (1 Viewer)

kengooch

Member
Local time
Today, 12:33
Joined
Feb 29, 2012
Messages
109
I am trying to pass the filter from my from that I selected from an unbound Combo Box to a Report.
The Unbound Combo Box obtains it's data from the tDept Table which
Sample Data:

The code to select the Department is below:
Code:
'------------------------------------------------------------
'Show Records by Department
'------------------------------------------------------------
Private Sub luDept_AfterUpdate()
On Error GoTo luDept_AfterUpdate_Err
    DoCmd.SearchForRecord , "", acFirst, "[tDeptAbbrv] = " & "'" & Screen.ActiveControl & "'"
    luDept = Null
    DoCmd.GoToControl "luPlcyNm"
luDept_AfterUpdate_Exit:
    Exit Sub
luDept_AfterUpdate_Err:
    MsgBox Error$
    Resume luDept_AfterUpdate_Exit
End Sub

Code:
Private Sub bPlcyCmplt_Click()
'This Code Handles the Report based upon the Filter selections
MsgBox "pause"
    DoCmd.OpenReport "rPolicyComplete", acViewReport, , "tPlcydpt = " & [tPlcydpt]
    With Reports("rPolicyComplete")
        .OrderBy = "tplcyspID"
        .OrderByOn = True
    End With
End Sub

I have a button on the Form to Print the Report and I have the following Code in it.
 
Last edited by a moderator:

Ranman256

Well-known member
Local time
Today, 15:33
Joined
Apr 9, 2015
Messages
4,126
docmd.OpenReport "rMyRpt",acViewPreview , ,"[id]=" & txtID
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 20:33
Joined
Jul 9, 2003
Messages
14,652
In this YouTube video I demonstrate how to pass a filter into a Report from a Form no code required in the Report:-


I have a blog on filtering which may be of interest:-

 

kengooch

Member
Local time
Today, 12:33
Joined
Feb 29, 2012
Messages
109
In this YouTube video I demonstrate how to pass a filter into a Report from a Form no code required in the Report:-


I have a blog on filtering which may be of interest:-

This was a great video. Thanks so much! Helps me with some other things I am working on.
 

Users who are viewing this thread

Top Bottom