1
votes

I have a report embedded in a form containing a text box and a button.

My desire is to update the filter on the report and requery and refresh the report within the form. I am not very familiar with using VBA within access, so I may very well be completely off-base with how I'm attempting to do this.

The event that fires when the generateExhib button is clicked is below.

The report that is embedded as subform/subreport is named TagReport.

    Private Sub GenerateExhib_Click()



    If (generatePrintedExhib.Value = False) Then
        Me.TagReport.Application.DoCmd.SetFilter WhereCondition:="[Exhibitor ID] =" + ExhibitorNumber.Value + " AND [UDEntry-CheckBox1] = false"
    Else
        Me.TagReport.Application.DoCmd.SetFilter WhereCondition:="[Exhibitor ID] =" + ExhibitorNumber.Value
    End If


    Me.TagReport.Report.Application.DoCmd.Requery
    Me.TagReport.Report.Application.DoCmd.RefreshRecord


End Sub
1
Not sure it's the culprit so I'm gonna post this as a comment, but why are you going through the whole rigmarole of Me.TagReport.Report.Application.DoCmd.Requery instead of just Me.TagReport.Requery? - Aiken

1 Answers

0
votes

I created a little test form with an embedded report, a combo box with values to filter on, and a refresh button. In the button's click event I added the following code:

Private Sub cmdRefresh_Click()
    Dim filter As String

    filter = "CardCode = '" & Me.cmbFilter.Value & "'"

    '"subform_rpt" is the specific name of the embedded report. 
    DoCmd.ApplyFilter "Filter", filter, "subform_rpt"

End Sub

Works quite nicely for me. I hope this will help.