473,225 Members | 1,616 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,225 software developers and data experts.

How to get the filter string from a subform tied to a query

2
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the filter string once the user filters the query though the subform and use it to create a temp query that populates a report of the filtered data. Here is the VBA I've been trying:

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
Thoughts anyone...thanks inadvance
Jan 19 '24 #1
0 14040

Sign in to post your reply or Sign up for a free account.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.