Setting recordsource of a report using openarg

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • munkee
    Contributor
    • Feb 2010
    • 374

    #1

    Setting recordsource of a report using openarg

    I use a modified version of the Allen Browne filter script to select records from a query.

    The code concludes with the following statement to create the SQL to select the correct records:

    Code:
    Me.subfrmlogforfiltering.Form.RecordSource = "Select " & topinsert & " * FROM logforfiltering WHERE " & strWhere
    I am then trying to pass this through a print button as openargs so the records shown load up in the report:

    Code:
    DoCmd.OpenReport "rptlogforfiltering", acViewPreview, OpenArgs:=Me.subfrmlogforfiltering.Form.RecordSource
    Then in the report I have:

    Code:
    Private Sub Report_Open(Cancel As Integer)
    Me.RecordSource = Me.OpenArgs
    End Sub
    However the form is just opening with an empty record. Can anyone see anything missing here? I have used a debug.print to show what is being sent in the open args and all seems correct. I have also checked the recordsource and this is showing the correct sql also but no records being shown...

    Code:
    Openargs print: Select All * FROM logforfiltering WHERE (([NCStatus] = 'Initial Notification'))
    Recordsource print: Select All * FROM logforfiltering WHERE (([NCStatus] = 'Initial Notification'))
  • munkee
    Contributor
    • Feb 2010
    • 374

    #2
    fixed!

    for some reason the report had the filter as (false). Therefore stopping any records being displayed. Deleting this out did the trick.

    Comment

    Working...