I have a form called frmDiceInventory with a subform called subfrmDice who's control source is set to a query call qryDiceInventory. What I'm trying to achieve is to pick up the filter string from the subform once the end user filters the data to create a query to populate a report to print the filtered data.
here is the code I've attempted to use:
Private Sub cmdPrint_Click()
Dim sSQL As String
sSQL = "Select * From tblDiceInventory"
If Len(Me.Filter) > 0 Then
sSQL = sSQL & " Where " & Me.Filter
End If
If Len(Me.OrderBy) > 0 Then
sSQL = sSQL & " Order By tblDiceInventory.Customer Name"
End If
Call DBEngine.Workspaces(0).Databases(0).CreateQueryDef("qryFilter", sSQL)
DoCmd.OpenReport "rptdiceinventory", acViewPreview, , strFilter
End Sub